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) = ?)

With 7.4.3.14 this bug will be fixed. There is no timeschedule so far.
The problem occurs when more than 1 correlated subquery
is in the select and if at least one of it is a so-called <scalar_subquery>
combined with a parameter (the '?').

The workaround (as written before) is to write a function around the ?
which is only valid for the corresponding datatype.
Starting with 7.4.3.14 this function is not needed any more.

Elke
SAP Labs Berlin



> 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(ReplyPacket.java:69)
>         at 
> com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:720)
>         at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:405)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1507)
>         at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:736)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:226)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:177)
>         at 
> com.sap.dbtech.jdbc.CallableStatementSapDB.<init>(CallableStatementSapDB.java:81)
>         at 
> com.sap.dbtech.jdbc.ConnectionSapDB.prepareStatement(ConnectionSapDB.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.

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

Reply via email to