$sqlrc = $session->sql ($cmd_string);
You can also use the methods cmd or rawCmd to execute SQL statements. However, if exceptions are raised when you do this, you must recognize them yourself, and find the error code in the text of the exception.
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, an exception of the type LoaderError is raised.
Executing a valid SQL statement
print $session->cmd ('CREATE TABLE testtable3 (a integer)');
Executing an invalid SQL statement
print $session->cmd ('invalid command');
The output is the error code of the SQL statement:
Executing an invalid Loader command
print $session->cmd ('dataload invalid spec')
The output is the exception of the Loader Server:
Error Loader Server: Syntax error at position 10 (Unexpected token: invalid). at /opt/sdb/programs/misc/SAP/DBTech/loader.pm line 89.