Problem:
Compiling this statement
EXEC SQL
SELECT
nextval for myseq
INTO
:hostvar
FROM MYTABLE WHERE COL1 = 10
END-EXEC
returns this compiler error :
COBES0100S Incorrect SQL statement syntax near
: sample.cbl(23,20)
Resolution:
OpenESQL is designed to support ANSI-standard SQL. As the NEXTVAL and PREVVAL clauses are not part of the standard, you cannot use them with static SQL when using OpenESQL.
Instead, you should use dynamic SQL should be used to execute the statement.
.....
exec sql declare vcurs cursor for dynamic_sql end-exec
.....
move "select nextval for myseq from MYTABLE where COL1=10"
to sql-text
.....
See the DYNAMIC sample under the Examples\\ODBCESQL directory for further details on using Dynamic SQL.