Restricted Statements in Single-Statement Prepares

In general, you can prepare any data manipulation language (DML) statement.

In HCL OneDB™, you can prepare any single SQL statement except for the following statements:
  • ALLOCATE COLLECTION
  • ALLOCATE DESCRIPTOR
  • ALLOCATE ROW
  • CLOSE
  • CONNECT
  • CREATE FUNCTION FROM
  • CREATE PROCEDURE FROM
  • CREATE ROUTINE FROM
  • DEALLOCATE COLLECTION
  • DEALLOCATE DESCRIPTOR
  • DEALLOCATE ROW
  • DECLARE
  • DESCRIBE
  • DISCONNECT
  • EXECUTE
  • EXECUTE IMMEDIATE
  • FETCH
  • FLUSH
  • FREE
  • GET DESCRIPTOR
  • GET DIAGNOSTICS
  • INFO
  • LOAD
  • OPEN
  • OUTPUT
  • PREPARE
  • PUT
  • SET AUTOFREE
  • SET CONNECTION
  • SET DEFERRED_PREPARE
  • SET DESCRIPTOR
  • UNLOAD
  • WHENEVER

You can prepare a SELECT statement. If SELECT includes the INTO TEMP clause, an ESQL/C program can execute the prepared statement with an EXECUTE statement. If it does not include the INTO TEMP clause, the statement returns rows of data. Use DECLARE, OPEN, and FETCH cursor statements to retrieve the rows.

In ESQL/C, a prepared SELECT statement can include a FOR UPDATE clause. This clause is used with the DECLARE statement to create an update cursor. The next example shows a SELECT statement with a FOR UPDATE clause in :
sprintf(up_query, "%s %s %s",
   "select * from customer ",
   "where customer_num between ? and ? ",
   "for update");
EXEC SQL prepare up_sel from :up_query;
EXEC SQL declare up_curs cursor for up_sel;
EXEC SQL open up_curs using :low_cust,:high_cust;