I am trying to do this regular SQL like statement in DB navigator, which uses OpenEdge Progress, but it kept saying syntax error:
exec('select * from myTable')
How do I do exec in Open Edge?
Can you run it without the exec? Just simply type in the query and press the run button on the top of the editor.
I need to generate a dynamic select statement:
e.g. in SQL we do:
if "A" = "B"
exec('select id, a from myTable')
else
exec('select id, b from myTable')
You want to be doing this with dynamic queries and ABL statements, not SQL.
Can you tell us a little more of what you are trying to accomplish? Generally if you are writing .p code you don't want to be writing SQL statements, but instead do as Thomas suggested which is to write ABL dynamic queries. If you using the SQL editor and runnning SQL queries against the OpenEdge database the best place is to look up syntax is in the help files.
The SQL reference can be found here on the communities site:
http://communities.progress.com/pcom/docs/DOC-103525
If you are trying to run SQL in the ABL then it would be better to write ABL code instead.
Something like your above code would end up as either a for each statement or a query:
as a for each statement:
for each myTable:
// do something
end.
As a dynamic query it would look something like this:
DEF VAR bmyTable AS HANDLE NO-UNDO.
CREATE BUFFER bmyTable FOR TABLE "myTable".
CREATE QUERY xQuery.xQuery:SET-BUFFERS(bmytable).
xQuery:QUERY-PREPARE("for each bmytable").
xQuery:QUERY-OPEN().
xQuery:GET-FIRST()....
You can also do this with a static query.