execute (sqlParms = [])
execute is a method of the class SapDB_Prepared. This method executes the statement with the parameters specified in parameterlist.
In the parameter list, enter only input parameters. If the executed statement gets output parameters, then the method returns them as a tuple.
The type of the result depends on the content of the SQL statement (see Possible SQL Results).
Example 1: Executing a data query
select =
session.prepare ('SELECT * FROM messages WHERE msgno = ?')
select.execute ([300])
Result
<SapDB_ResultSet object at …>
Example 2: Calling a stored procedure
Generating a stored procedure
session.sql ("""CREATE
DBPROC paramdemo (
IN p1 FIXED (5),
INOUT p2 FIXED,
OUT p3 FLOAT)
AS BEGIN
SET p2 = 2;
SET p3 = 3.0;
END;""")
Generating an object of the class SapDB_Prepared for calling a stored procedure
call = session.prepare
('call paramdemo (?, ?, ?)')
in1 = 1 # sets p1
in2 = 2 # set
p2
Calling the stored procedure and getting the output parameters
out2, out3 = call.execute
([in1, in2])
print 'value p2:', out2
print 'value p3:', out3
Result
value p2: 2
value p3: 3.0