Elias Martenson wrote:

> I'm getting an interesting error when doing a prepared 
> statement (but it
> works when using non-prepared statements).
> 
> Here's the table definition:
> 
>       create table foo (id fixed(20) primary key, x 
> fixed(20), y fixed(20))
> 
>       create table bar (id fixed(20) primary key)
> 
> Here's the query:
> 
>       select * from foo foo1
>               where ((select o2.id from bar o2 where foo1.x = 
> o2.id) = ?) or
>                       ((select m3.id from bar m3 where foo1.y 
> = m3.id) = ?)
> 
> Don't mind the silliness of the query. It's was originally 
> much larger,
> and auth-generated from an EJB container. I've reduced it to make it
> easier to analyse.
> 
> When I run the above SQL through 
> Connection.prepareStatement() I'm getting
> the following exception:
> 
> Exception in thread "main" 
> com.sap.dbtech.jdbc.exceptions.DatabaseException: [21000]: 
> Message not available
>         at 
> com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPa
> cket.java:69)
>         at 
> com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSa
> pDB.java:720)
>         at 
> com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:405)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.sendCommand(Callabl
> eStatementSapDB.java:1507)
>         at 
> com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:736)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.doParse(CallableSta
> tementSapDB.java:226)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.constructor(Callabl
> eStatementSapDB.java:177)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.<init>(CallableStat
> ementSapDB.java:81)
>         at 
> com.sap.dbtech.jdbc.ConnectionSapDB.prepareStatement(Connectio
> nSapDB.java:614)
>         at Foo.main(Foo.java:11)
> 
> But when I run it through Statement.executeQuery() (and 
> replacing the "?"
> characters by the number "2") I'm getting the expected result.
> 
> Error 21000 is not even in the error messages list so I have 
> no idea in
> which direction to look.

21000 is an internal error which should never be returned to the user.
Oops
We will fix this problem within the next versions.
A workaround should be to tell the (stupid) kernel which kind,
i.e. of which datatype, the parameters are by surrounding them
with a function working only on the corresponding datatype:
ABS or FIXED for numbers for example, SUBSTR (?, 1)
for character data and so on.
I hope you will be able to change the statement although it
is a somehow prepared one.

Sorry for any inconveniences

Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to