sqlX is a method of the SapDB_Session class (sdb.sql module). With this method, you can execute SQL statements with parameters without first having to create an object of the SapDB_Prepared class (sdb.sql module).
Syntax
sqlX (cmd, parms = [])
Attribute |
Description |
---|---|
cmd |
SQL statement Can contain the following placeholders: ? | :<varname> |
parms |
Parameter list from which the system replaces the placeholders for parameters |
Result:
Successful execution: See Possible SQL Results
if an error occurs: Exception of the SQLError class (sdb.sql module)
You execute a SELECT statement that contains a parameter:
Syntax
cursor = session.sqlX ('SELECT firstname, name, cno FROM hotel.customer WHERE cno>?',[3000])
The cursor variable contains an object of the SapDB_ResultSet class (sdb.sql module). You can use this object to access the data records in the result set.
You execute a DELETE statement that contains a parameter:
Syntax
rowsDeleted = session.sqlX ('DELETE FROM hotel.person WHERE name = ?',['NY'])
The rowsDeleted variable contains the number of lines deleted by the DELETE statement.