Difference between revisions of "PREPARE"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Set up an SQL statement for subsequent execution | Set up an SQL statement for subsequent execution | ||
Line 30: | Line 23: | ||
|- | |- | ||
|} | |} | ||
+ | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
stmtbuf = 'SELECT * FROM customers WHERE contactnam = ?' | stmtbuf = 'SELECT * FROM customers WHERE contactnam = ?' | ||
− | + | prepare mystmt from :stmtbuf | |
− | prepare mystmt from :stmtbuf | + | |
gcAuthor = 'Ann Devon' | gcAuthor = 'Ann Devon' | ||
− | + | execute mystmt using :gcAuthor | |
− | execute mystmt using :gcAuthor | + | |
gcAuthor = 'Yang Wang' | gcAuthor = 'Yang Wang' | ||
− | + | execute mystmt using :gcAuthor | |
− | execute mystmt using :gcAuthor | + | |
stmtbuf = 'INSERT INTO customers (customerid, companynam, contactnam) VALUES (?,?,?)' | stmtbuf = 'INSERT INTO customers (customerid, companynam, contactnam) VALUES (?,?,?)' | ||
− | + | prepare mystmt from :stmtbuf | |
− | prepare mystmt from :stmtbuf | + | |
buf1 = '00101' | buf1 = '00101' | ||
buf2 = 'Recital' | buf2 = 'Recital' | ||
buf3 = 'US' | buf3 = 'US' | ||
− | + | execute mystmt using :buf1, :buf2, :buf3 | |
− | execute mystmt using :buf1, :buf2, :buf3 | + | |
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
[[Category:Commands]] | [[Category:Commands]] |
Latest revision as of 15:56, 22 December 2009
Purpose
Set up an SQL statement for subsequent execution
Syntax
PREPARE <statement> FROM :<variable>
See Also
Description
The PREPARE command is used to set up an SQL statement for subsequent execution. The EXECUTE command is used to execute the statement. Variables used as parameters in the SQL statement must be declared before execution.
Keywords | Description |
---|---|
statement | An identifier for the SQL statement. |
variable | The name of a variable containing the SQL statement as a string |
Example
stmtbuf = 'SELECT * FROM customers WHERE contactnam = ?' prepare mystmt from :stmtbuf gcAuthor = 'Ann Devon' execute mystmt using :gcAuthor gcAuthor = 'Yang Wang' execute mystmt using :gcAuthor stmtbuf = 'INSERT INTO customers (customerid, companynam, contactnam) VALUES (?,?,?)' prepare mystmt from :stmtbuf buf1 = '00101' buf2 = 'Recital' buf3 = 'US' execute mystmt using :buf1, :buf2, :buf3
Products
Recital Server, Recital