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

 

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

Syntax Syntax

  1. sqlX (cmd, parms = [])
End of the code.
sqlX Method: Attributes

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:

    Syntax Syntax

    1. cursor = session.sqlX ('SELECT firstname, name, cno FROM hotel.customer WHERE cno>?',[3000])
    End of the code.

    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 Syntax

    1. rowsDeleted = session.sqlX ('DELETE FROM hotel.person WHERE name = ?',['NY'])
    End of the code.

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