Please enable JavaScript to view this site.

ESL Documentation

Batch Command (ORACLE and ODBC Only)
Identify a statement for use in batch commands.

astmt SQL_STATEMENT 

SQL_STATEMENT 

An SQL SELECT, INSERT, UPDATE, or DELETE statement.

Description

Use this command to identify the SELECT, INSERT, UPDATE, or DELETE statement you want used in subsequent batch commands. You can follow astmt only with an aval command; no other SQL statements are allowed and will result in an error and the batch mode being terminated.

Note that, for parsing purposes, you must provide one placeholder in the statement for each field into which you will place data. You may provide actual data values instead of placeholders, but if you do, use only single quotes (' ') around the data value; e.g., 'SMITH'. With ORACLE refer to the ORACLE manual Programmer's Guide to the ORACLE Precompilers (specifically, the sections on "Using Host Arrays" and "Using Dynamic SQL") for more information about the use of placeholders. With OBDC, the astmt calls the SQLPrepare function that expects placeholders to be the "?" characters, refer to Microsoft's documentation for the SQLPrepare function for more information.

During the parsing and preparation of the SQL statement, memory buffers are allocated with the size determined by the database's definition of the field. All the input field are defined as character and are converted to the required data type when the SQL statement is executed.

Example

subroutine ProcessSQLCommand(string: Command_SV) is

 begin guarded

         response to start

                 send Command_SV to SQL

         response to "SQL>"

                 leave block

 end

 

response to BeginORACLEInsert 

 copy "asize 10\n" to SQLCommand_ASV

 call ProcessSQLCommand(SQLCommand_ASV)

 copy "astmt insert into emp (ename, enum) values (:x, :y)\n" to SQLCommand_ASV
 call ProcessSQLCommand(SQLCommand_ASV)

 for x = 1 to 10 loop

         copy "aval JONES, "(100*x)"\n" to SQLCommand_ASV
         call ProcessSQLCommand(SQLCommand_ASV)

 end loop
 copy "aexec\n" to SQLCommand_ASV

 call ProcessSQLCommand(SQLCommand_ASV)

 

response to BeginODBCInsert 

 copy "astmt insert into emp (ename, enum) values (:x, :y)\n" to SQLCommand_ASV
 call ProcessSQLCommand(SQLCommand_ASV)

 for x = 1 to 10 loop

         copy "aval JONES, "(100*x)"\n" to SQLCommand_ASV
         call ProcessSQLCommand(SQLCommand_ASV)

         copy "aexec\n" to SQLCommand_ASV

         call ProcessSQLCommand(SQLCommand_ASV)

 end loop