Entering content frame

 Method sql 

Definition

sql (cmd_string)

Use

sql is a method of the class Loader. You use this method to send the Loader command specified under cmd_string to the program Loader Server.

Result

If the statement is executed successfully, the value of the result is 0.

If the execution of the statement causes an SQL error, the number of the error message of the SQL statement is returned.

If the execution of the statement causes a Loader error, the exception LoaderError is raised.

Executing a valid SQL statement

session.cmd ('CREATE TABLE testtable3 (a integer)')

Output:

0

 

Executing an invalid SQL statement

session.cmd ('invalid command')

The output is the error code of the SQL statement:

3005

 

Executing an invalid Loader command

session.cmd ('DATALOAD invalid spec')

The output is the exception of the Loader Server:

Traceback (innermost last):
loader.LoaderError: loader.LoaderError: [-25281] Syntax error at position 10 (Unexpected token: invalid)

 

Leaving content frame