The EGL prepare statement specifies an SQL PREPARE statement, which optionally includes details that are known only at run time. You run the prepared SQL statement by running an EGL execute statement or (if the SQL statement returns a result set) by running an EGL open or get statement.
try prepare prep01 from "insert into " + aTableName + "(empnum, empname) " + "value ?, ?" for empRecord; onException if empRecord is unique myErrorHandler(8); else myErrorHandler(12); end end
myString = "insert into myTable " + "(empnum, empname) " + "value ?, ?"; try prepare myStatement from myString; onException myErrorHandler(12); // exits the program end try execute myStatement using :myRecord.empnum, :myRecord.empname; onException myErrorHandler(15); end
As shown in the previous examples, the developer can use a question mark (?) where a host variable should appear. Then, the name of the host variable used at run time is placed in the using clause of the execute, open, or get statement that runs the prepared statement.
prepare prep02 from "update myTable " + "set empname = ?, empphone = ? where current of x1" ; execute prep02 using empname, empphone ; freeSQL prep02;
For a example of how parentheses affect the use of a plus (+) sign, see Expressions.
Related concepts
References to parts
Record types and properties
SQL support