Difference between revisions of "EXECUTE"

From Recital Documentation Wiki
Jump to: navigation, search
(Class)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
 
 
==Purpose==
 
==Purpose==
 
Executes an SQL statement previously set up using the PREPARE command
 
Executes an SQL statement previously set up using the PREPARE command
Line 33: Line 31:
 
<code lang="recital">
 
<code lang="recital">
 
stmtbuf = 'SELECT * FROM customers WHERE contactnam = ?'
 
stmtbuf = 'SELECT * FROM customers WHERE contactnam = ?'
EXEC SQL
+
PREPARE mystmt FROM :stmtbuf
    PREPARE mystmt FROM :stmtbuf;
+
  
 
gcAuthor = 'Ann Devon'
 
gcAuthor = 'Ann Devon'
EXEC SQL
+
EXECUTE mystmt USING :gcAuthor
    EXECUTE mystmt USING :gcAuthor;
+
  
 
gcAuthor = 'Yang Wang'
 
gcAuthor = 'Yang Wang'
EXEC SQL
+
EXECUTE mystmt USING :gcAuthor
    EXECUTE mystmt USING :gcAuthor;
+
  
 
stmtbuf = 'INSERT INTO customers (customerid, companynam, contactnam) VALUES (?,?,?)'
 
stmtbuf = 'INSERT INTO customers (customerid, companynam, contactnam) VALUES (?,?,?)'
EXEC SQL
+
PREPARE mystmt FROM :stmtbuf
    PREPARE mystmt FROM :stmtbuf;
+
  
 
buf1 = '00101'
 
buf1 = '00101'
 
buf2 = 'Recital'
 
buf2 = 'Recital'
 
buf3 = 'US'
 
buf3 = 'US'
EXEC SQL
+
EXECUTE mystmt USING :buf1, :buf2, :buf3
    EXECUTE mystmt USING :buf1, :buf2, :buf3;
+
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]
 
[[Category:Commands]]
 
[[Category:Commands]]

Latest revision as of 15:53, 22 December 2009

Purpose

Executes an SQL statement previously set up using the PREPARE command


Syntax

EXECUTE <statement> USING :<variable>[,<variable2>[,...]]


See Also

EXECUTE IMMEDIATE, PREPARE


Description

The EXECUTE command is used to execute an SQL statement previously set up using the PREPARE command. Variables used as parameters in the SQL statement must be declared before execution.


Keywords Description
statement An identifier for the SQL statement previously set up using PREPARE
variable The name of a variable to be used as the first parameter to the SQL statement
variable2... The names of variables to be used as the subsequent parameters to the SQL statement


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