Show TOC

sqlX Method (SapDB_Session Class)Locate this document in the navigation structure

Use

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).

Features
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:

Example
  • You execute a SELECT statement that contains a parameter:

    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:

    rowsDeleted = session.sqlX ('DELETE FROM hotel.person WHERE name = ?',['NY'])
    					

    The rowsDeleted variable contains the number of lines deleted by the DELETE statement.