|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
RE: Passing parameters from java
From: Schroeder, Alexander (alexander.schroeder
sap.com)
Date: Thu Jun 10 2004 - 05:37:38 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello Fabio,
apparantly the statement chokes the database kernel as it seems unable to guess
what type the 1st parameter has. However, it should not react in the way you
have experienced even if there may be no way for it to find out what type a
parameter has.
A workaround would be placing a 'dummy' SUBSTR call into the decode,
which convinces the kernel that the 1st parameter is a string:
SELECT 1 FROM DUAL WHERE DECODE(SUBSTR(?, 1) '1', 'ONE', 'NOT_ONE') = 'ONE' AND ? = 'guest'
at least seemed to work in my test.
Thanks for reporting the issue, and sorry for any inconvenience caused.
Alexander Schröder
SAP DB, SAP Labs Berlin
> -----Original Message-----
> From: Fabio Pinotti [mailto:fabio.pinotti
icteam.it]
> Sent: Thursday, June 10, 2004 11:19 AM
> To: maxdb
lists.mysql.com
> Subject: Passing parameters from java
>
>
> Hi,
> I have this simple piece of java code that gives me an
> error (it is just a dummy slq expresson that include the
> error I get on a more complex query...):
>
> String sqlString="Select 1 FROM DUAL WHERE
> " DECODE(?,'1','ONE','NOT_ONE')='ONE'" +
> " AND ?='guest'";
>
> PreparedStatement st= cn.prepareStatement(sqlString);
> st.setObject(1,"0");
> st.setObject(2,"guest");
> ResultSet rs=st.executeQuery();
>
> The error is
>
> javax.servlet.ServletException: SAP DBTech JDBC: Parameter 1:
> value too large.
>
> The connection seems to be valid, because I succesfully
> execute other sql commands.
> The strange thing is that the following statement, executed
> with the same code above, runs succesfully
>
> String sqlString="Select 1 FROM DUAL WHERE " +
> " ?='1'" +
> " AND ?='guest'";
>
> so it seems that the problem is raised by "decode"....
> I tried to specify parameter types, or to use setString
> instead of setObject, but nothing changes.
>
>
> Thanks
>
> Fabio
>
--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]