The main use of the PASSTHRU statement is to issue administrative commands to databases (for example, to create a table).
Note: Do not use PASSTHRU to call stored procedures; instead, use the CALL statement because PASSTHRU imposes limitations (you cannot use output parameters, for example).Uses specified ODBC data source Name.
- Only DDL Statements (CREATE, DROP , ALTER) requires PASSTHRU in a compute node.
Examples :
The following example creates the table Customers in schema Shop in database DSN1:
PASSTHRU 'CREATE TABLE Shop.Customers (
CustomerNumber INTEGER, FirstName VARCHAR(256), LastName VARCHAR(256), Street VARCHAR(256), City VARCHAR(256), Country VARCHAR(256) )' TO Database.DSN1; |
If, as in the last example, the ESQL statement is specified as a string literal, you must put single quotation marks around it. If, however, it is specified as a variable, omit the quotation marks.
For example:
SET myVar = 'SELECT * FROM user1.stocktable';
SET OutputRoot.XMLNS.Data[] = PASSTHRU(myVar); |
The following example "drops" (that is, deletes) the table Customers from schema Shop in database DSN1:
PASSTHRU 'DROP TABLE Shop.Customers' TO Database.DSN1;
|