Installation guide

5. mxODBC Overview
Results can be retrieved through output parameter, input/output parameters, or
result sets. Depending on the database backend, it is also possible to combine
both.
Retrieving output parameters from stored procedures
When not providing the optional parametertypes parameter as in the above
example, all parameters are considered to be input parameters, so
results will
be a list copy of
parameters.
If you want to use input/output or output parameters, you have to specify the
parametertypes parameter to define how to bind the variables to the procedure
parameters:
results = cursor.callproc("myprocedure", parameters, parametertypes)
Please see section 5.6.3 Input/Output and Output Parameters for more details on
how to use
parametertypes.
Values from input/output and output parameters will then be updated in the
results list copy as returned by the stored procedure.
Example:
from mx.ODBC.unixODBC import SQL
results = cursor.callproc('sp_params',
[1, 0],
parametertypes=(SQL.PARAM_INPUT,
SQL.PARAM_OUTPUT))
if results == [1, 3]:
print 'Works.'
Retrieving result sets from stored procedures
The cursor.callproc() method can also be used to call stored procedures
which generate result sets. These can then be fetched using the standard
cursor.fetch*() methods. If the stored procedure has generate multiple result
sets, skipping to the next result set is possible by calling the
.nextset() cursor
method.
Please see section 5.6.5 Using Result Sets for passing back Output Data for
details.
Example:
cursor.callproc('sp_result_set', [1])
result_set = cursor.fetchall()
5.6.2 Calling Stored Procedures with cursor.execute*()
Methods
Stored procedures and functions can also be called indirectly using the following
standard ODBC syntax for calling stored procedures.
69