getDescription is a method of the SapDB_Prepared class (sdb.sql module). You can use this method to display information about the parameters of SQL statements.
Syntax
getDescription ()
This method returns the following properties of the parameters in the SQL statement:
Name (empty string as a placeholder)
Type (as a string)
Type (as an integer according to the ODBC specification)
Logical size (maximum number of characters in a string parameter, maximum number of numbers in a numeric parameter)
Number of decimal places
Indicator that specifies whether the parameter can be NULL
Type: 'IN' |'OUT' | 'IN/OUT'
You create the avg_price database procedure:
Syntax
session.sql ("""CREATE DBPROCEDURE avg_price (IN zip CHAR(5), OUT avg_price FIXED(6,2)) AS VAR sum FIXED(10,2); price FIXED(6,2); hotels INTEGER; TRY SET sum = 0; SET hotels = 0; DECLARE dbproccursor CURSOR FOR SELECT price FROM hotel.room,hotel.hotel WHERE zip = :zip AND room.hno = hotel.hno AND type = 'single'; WHILE $rc = 0 DO BEGIN FETCH dbproccursor INTO :price; SET sum = sum + price; SET hotels = hotels + 1; END; CATCH IF $rc <> 100 THEN STOP ($rc, 'unexpected error'); CLOSE dbproccursor; IF hotels > 0 THEN SET avg_price = sum / hotels ELSE STOP (100, 'no hotel found');""")
You create an object of the SapDB_Prepared class using the prepare method:
Syntax
call = session.prepare ('call avg_price (?, ?)')
You display the information about the parameters in formatted form:
Syntax
print "colname type code length frac null? in/out" print "====================================================" for parameterDescription in call.getDescription (): print "%-10s %-10s %4d %6d %2d %5s %s" % parameterDescription
colname type code length frac null? in/out
====================================================
Unicode 1 5 0 1 IN
Fixed 3 6 2 1 OUT