Function documentationgetDescription Method (SapDB_Prepared Class) Locate this document in the navigation structure

 

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.

Features

Syntax Syntax

  1. getDescription ()
End of the code.
Result

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'

Example

You create the avg_price database procedure:

Syntax Syntax

  1. 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');""")
    
End of the code.

You create an object of the SapDB_Prepared class using the prepare method:

Syntax Syntax

  1. call = session.prepare ('call avg_price (?, ?)')
End of the code.

You display the information about the parameters in formatted form:

Syntax Syntax

  1. print "colname type code length frac null? in/out"
    print "===================================================="
    for parameterDescription in call.getDescription ():
      print "%-10s %-10s %4d %6d %2d %5s %s" % parameterDescription
    
End of the code.
Result

colname type code length frac null? in/out

====================================================

Unicode 1 5 0 1 IN

Fixed 3 6 2 1 OUT