Method getDescription


getDescription is a method of the class SapDB_Prepared.

With this method you display information about the parameters of an SQL statement.


getDescription ()


?     Empty string as a placeholder for the name of the parameter

?     Type of the parameter (as a string)

?     Type of the parameter (as an integer)

These numbers have the same meaning as they do in the ODBC specification.

?     logical size of the parameter (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 of parameter: 'IN' |'OUT' | 'IN/OUT'


You create the database procedure avg_price:

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;


  SET sum = 0; SET hotels = 0;

  DECLARE dbproccursor CURSOR FOR

  SELECT price FROM,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;



  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');""")

With the prepare method, you create an object of the class SapDB_Prepared:

call = session.prepare ('call avg_price (?, ?)')

You display the information about the parameters in a formatted form:

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