It's really not equivalent. Your Case 2 was:

<c:set var="nullValue" value="null"/>

Which sets nullValue to the String literal "null". I suggested the equivalent
of:

<c:set var="nullValue" value="${null}"/>

Which will set nullValue to null (meaning that nullValue will actually be
removed from page scope). Did you actually try it and got the same error?

Quoting Derek Mahar <[EMAIL PROTECTED]>:

> Your solution is equivalent to Case 2 that I listed in my original
> message.  The Microsoft SQL Server JDBC driver complains with a
> JspException:
> 
> javax.servlet.ServletException: javax.servlet.jsp.JspException: 
>   INSERT INTO tblTest(a) VALUES (?)
> : [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Syntax error 
> converting the nvarchar value 'null' to a column of data type int.
> 
> However, the JDBC driver accepts and correctly processes the following
> query:
> 
> <sql:update>
>   INSERT INTO tblTestDerek VALUES (null)
> </sql:update>
> 
> In light of this, I suspect that there may be an error in the
> implementation of <sql:param> where it treats "null" as a string
> argument rather than as an SQL null argument.
> 
> Derek
> 
> -----Original Message-----
> From: Kris Schneider [mailto:[EMAIL PROTECTED] 
> Sent: May 18, 2004 9:10 PM
> To: Tag Libraries Users List
> Subject: Re: [JSTL] How do I enter a null value with <sql:param>?
> 
> 
> <sql:param value="${null}"/>
> 
> Derek Mahar wrote:
> > How do I enter a null value into a table column with <sql:param>?  The
> 
> > JSTL 1.1 specification states for <sql:param> that, "If value is null,
> 
> > the parameter is set to the SQL value NULL."  However, no matter what 
> > value I pass to <sql:param>, I'm unable to set a null column:
> > 
> > Case 1: Set value to undefined variable
> > <sql:update>
> >   INSERT INTO tblTest(a) VALUES (?)
> >   <sql:param value="${nullValue}"/>
> > </sql:update>
> > 
> > Output:
> > javax.servlet.ServletException: javax.servlet.jsp.JspException: 
> >   INSERT INTO tblTest(a) VALUES (?)
> > : [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is
> 
> > not supported by this driver.
> > 
> > Case 2: Set value to "null"
> > <c:set var="nullValue" value="null"/>
> > <sql:update>
> >   INSERT INTO tblTest(a) VALUES (?)
> >   <sql:param value="${nullValue}"/>
> > </sql:update>
> > 
> > Output:
> > javax.servlet.ServletException: javax.servlet.jsp.JspException: 
> >   INSERT INTO tblTest(a) VALUES (?)
> > : [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Syntax error 
> > converting the nvarchar value 'null' to a column of data type int.
> > 
> > Cast 3: Set value to empty string
> > <c:set var="nullValue" value=""/>
> > <sql:update>
> >   INSERT INTO tblTest(a) VALUES (?)
> >   <sql:param value="${nullValue}"/>
> > </sql:update>
> > 
> > Output:
> > Microsoft SQL Server inserts a new row with column a set to 0.
> > 
> > Any suggestions?
> > 
> > Derek
> 
> -- 
> Kris Schneider <mailto:[EMAIL PROTECTED]>
> D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to