prepare is a method of the SapDB_Session class (sdb.sql module). You can use this method to send SQL statements to the database in order for them to be checked.
Syntax
prepare (cmd)
Attribute |
Description |
---|---|
cmd |
SQL statement |
Result:
Successful execution: Object of the SapDB_Prepared class (sdb.sql module)
You can use this object to execute the same SQL statement multiple times with different parameters (execute method (SapDB_Prepared class)). That way the database does not need to recheck the syntax and privileges each time.
If an error occurs: Exception of the SQLError class (sdb.sql module)
You send an INSERT statement to the database:
insert = session.prepare ('INSERT INTO hotel.city VALUES (?,?,?)')
The insert variable contains an object of the SapDB_Prepared class (sdb.sql module). You can use this object to execute the INSERT statement with different parameters.
Example: Executing an SQL Statement Multiple Times with Different Values