Consultor Eletrônico



Kbase P85513: SQL-92: Unable to reference field name containing hyphen using Java
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   6/22/2010
Status: Verified

SYMPTOM(s):

Cannot run Java stored procedures containing hyphen or underscore characters

[JDBC Progress Driver]:error in compiling the stored procedure

Stored procedure fails when field used in SQL statement contains hyphen character "-"

Field with hyphens is enclosed in double quotes (")

SQL-92: Unable to reference field name containing hyphen using Java

The following error appears on the client: Invalid column name

FACT(s) (Environment):

Using Java code with double quotes or single quotes does not help
Sample code:
ResultSet rset = stmt.executeQuery ("select COD-EMP,COD-SUB,NOM-SUB from PUB.SUB");
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

CAUSE:

The double quotes are not being interpreted correctly as part of the Java statement.

FIX:

In order for the JDBC driver to interpret the quotes surrounding the field name correctly and not as part of the Java statement used in the execution of the SQL statement, the escape character \ should precede the " ie Concatenate a Java literal double quote using \" (backslash + double quotes).

e.g:
ResultSet rset = stmt.executeQuery ("select " + "\"" + "COD-EMP" + "\"" +", " + "\"" + "COD-SUB" + "\"" + ", " + "\"" + "NOM-SUB" + "\"" + " from PUB.SUB");

CREATE PROCEDURE sales6()
BEGIN SQLIStatement Insert_sales6 = new SQLIStatement("INSERT INTO pub.salesperson(\"sales-id\",name) values('88', 'testsql') ");
Insert_sales6.execute();
END