Parameter Support for Dynamic Statements and Stored Procedures

Starting with 15.7 ESD#4, the Adaptive Server Enterprise extension module for Python supports decimal, money, and LOB as parameters for dynamic statements and stored procedures.

Decimal and money type parameters

The following is an example usage of decimal and money as parameters for a stored procedure:

cur.execute("""
    create procedure pyproc
    @m1 money,
    @m2 money output,
    @d1 decimal(5,3),
    @d2 decimal(5,3) output,
    as
    begin
        select @d2 = @d1
        select @m2 = @m1
    end
    """)

dec_in = decimal.Decimal('1.23')
dec_out = sybpydb.OutParam(decimal.Decimal('0.00'))

dec_in = decimal.Decimal('1.23')
dec_out = sybpydb.OutParam(decimal.Decimal('0.00'))
m_in = decimal.Decimal('9.87')
m_out = sybpydb.OutParam(decimal.Decimal('0.00'))
vals = cur.callproc('pyproc', (int_out, dec_in, dec_out, m_in, m_out))

print ("Status = %d" % cur.proc_status)
print ("decimal = %s" % vals[1])
print ("money= %s" % vals[3])

Support for date, time, datetime, and float parameters for stored procedures

The Adaptive Server Enterprise extension module for Python supports for date, time, datetime, and float parameters for stored procedures.

See callproc.py sample that demonstrates calling stored procedures with parameters of different datatypes including date, time, datetime, float, and integer. The sample also demonstrates the handling of output parameters.