new SqlExecutor(connection)
Creates an SqlExecutor object for a given database connection.
Parameters:
Name | Type | Description |
---|---|---|
connection |
$.db.Connection | database connection |
Example
var SqlExecutor = $.import('sap.hana.testtools.unit.util', 'sqlExecutor').SqlExecutor;
var connection = $.db.getConnection();
var sqlExecutor = new SqlExecutor(connection);
Methods
-
callProcedure(sql)
-
Executes a call statement.
Parameters:
Name Type Description sql
String call statement that should be executed Throws:
SQLExceptionExample
try { sqlExecutor.callProcedure('CALL "SCHEMA"."package.subpackage::procedure"(#InTable,#OutError) with overview'); } finally { connection.close(); }
-
execQuery(sql) → {module:tableDataSet~TableDataSet}
-
Executes a select statement and returns the results.
Parameters:
Name Type Description sql
String select statement that should be executed Throws:
SQLExceptionReturns:
table data set that contains the results of the select statementExample
try { var actualTableDataSet = sqlExecutor.execQuery('select 1 from dummy'); } finally { connection.close(); }
-
execSingle(sql)
-
Executes a common statement.
Parameters:
Name Type Description sql
String common statement that should be executed Throws:
SQLExceptionExample
//copies a table into a test schema try { sqlExecutor.execSingle('create column table TEST.ORDERS like SAP_HANA_TEST_DEMO.ORDERS with no data'); } finally { connection.close(); }
-
execSingleIgnoreFailing(sql)
-
Executes a common statement and ignores any error during execution.
Parameters:
Name Type Description sql
String common statement that should be executed Example
//tries to delete a test table if it exists sqlExecutor.execSingleIgnoreFailing('drop table TEST.ORDERS');