skip to main content

Embedded SQL Statements : PREPARE

PREPARE
The PREPARE statement encodes a dynamic SQL statement string and assigns it a name.
General format
EXEC SQL [AT Database]
  PREPARE { Prepared-Statement } FROM Sql-String
Syntax rules
1.
Prepared-Statement is a Nonnumeric Literal, as defined in the Definitions section of the Preface of this document.
2.
Host-Var must be USAGE HANDLE
3.
Sql-String is a host variable or a Nonnumeric Literal, as defined in the Definitions section of the Preface of this document.
General rules
1.
Sql-String may contain question marks (?) that will be replaced by constant values or host variables when the statement is executed using the USING clause.
2.
Database identifies the active connection that will execute the query and must be previously defined using a Format 4 DECLARE statement.
3.
Host-Var should be released throgh a FREE statement before reusing it to store another prepared statement.
Examples
Prepare 2 statements, one to insert a row and one to count how many records meet a criteria
exec sql
        "insert into cust_table values (2010,'Evan Raymond','New York')"
exec sql
exec sql
        "select count(*) from cust_table where cust_code > ?"
move 1990 to min-key
exec sql
display "Count of records with key > " min-key " : " the-count

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left