Stproc execute()
syntax: |
stproc.execute() |
return: |
number - 0 if the call was successful; otherwise, a nonzero status code based on the error message produced by the database. If the method returns a nonzero status code, use the associated Database's majorErrorCode and majorErrorMessage methods to interpret the meaning of the error.
|
description: |
This method executes the stored procedure of SQL statement. It allows execution of any stored procedure or SQL statement that uses data definition language (DDL) or data manipulation language (DML) statements supported by the database server and that do not return a cursor (such as CREATE, ALTER, or DROP).
Each database supports a standard core of DDL and DML statements. In addition, a database may support DDL and DML statements specific to that database vendor. Use execute to call any of those statements. However, a database vendor may provide functions that are not DDL or DML statements. Do not use execute to call a stored procedure using those functions. For example, do not call the Oracle describe function or the Informix load function from a stored procedure's execute method. Although the execute method can be used to perform data modification (INSERT, UPDATE, or DELETE statements), it is recommended that Cursor objects be used instead to achieve the same functionality. Using the Cursor object for these sorts of actions allows better database-type independence and also allows the use of binary large object (BLOb) data.
When using the execute method, the stored procedure's SQL statement must strictly conform to the syntax requirements of the database server. For example, some servers require each SQL statement be terminated with a semicolon. See the server documentation for more information. If a transaction has not been started with beginTransaction, the single statement is automatically immediately committed when the stored procedure's execute method is called.
|
see: |
#link <sedbc>, Stproc cursor(), Database majorErrorCode(), Database majorErrorMessage()
|
example: |
// Create a new database object, and // connect it to a data source var a = new Database; a.connect(DBEngine, DataSource, User, Password);
// execute the stored procedure 'SomeProc' var sp = a.storedProc("SomeProc"); sp.ItemID = 123; sp.execute();
// execute an SQL stored procedure sp = a.storedProc("delete from Items where Weight = ?"); sp[0] = 1000; sp.execute();
// clean up sp.close(); a.close(); |