Consultor Eletrônico



Kbase P126904: Why no parameters are allowed in select list of a PreparedStatement?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   04/03/2008
Status: Unverified

FACT(s) (Environment):

OpenEdge 10.x
All Supported Operating Systems

SYMPTOM(s):

No Params allowed in select list of PreparedStatement

select name, (case when name = ? then 22 else 33 end) from customer where name = ? group by name

java.sql.SQLException:
Message (throw): Exception in thread "main" [DataDirect][OpenEdge JDBC Driver][OpenEdge]
Message (excp): No Params allowed in select list

Stack Trace:
java.sql.SQLException: [DataDirect][OpenEdge JDBC Driver][OpenEdge] No Params allowed in select list
at com.ddtek.jdbc.openedge.client.OpenEdgeClientRequest.describeProcessReply(Unknown Source)
at com.ddtek.jdbc.openedge.client.OpenEdgeClientRequest.describe(Unknown Source)
at com.ddtek.jdbc.openedge.OpenEdgeImplStatement.execute(Unknown Source)
at com.ddtek.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.ddtek.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.ddtek.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)

CAUSE:

sql standard does not support "?" (dynamic parameters) in the select list.


FIX:

SQL-92 has to be able to describe to the application what the attributes of a SQL-92 statement's result set will look like. This includes the data type and size of every column in the result set. But, when parameters occur in the select list it is not possible to do this in general. This is because the parameter can have any data type and be any size. For example:
select ?, ?, ? from pub.customer;
In the particular example, we can see that this particular use of ?, when carefully analyzed, does not cause a problem. But the general ability to use ? in the select list cause huge, if not impossible, problems.
For that reason it is not possible to reliably, consistently support general use of ? in the select list.