SQLDA Usage_Dynamic SQL

SQLDA USE in Dynamic SQL:

Db2 uses the SQL Descriptor Area(SQLDA) to communicate the dynamic SQL information to the application program.

It contains the various information like type of SQL, length, pointer to the actual data & number of columns etc. which are very useful for better coding.

To get this information into SQLDA after preparing the dynamic Query it should be described.

Ex: 

EXEC SQL
     OPEN CUR-DYN using DESCRIPTOR: WW-SQLDA
END-SQL

 

Below are the different SQLDA fields and sample sqlda structure

  • SQLDAID – Contains an eye catcher of “SQLDA” for use in storage dumps.
  • * If there is any CCSID override, it should contain the value ‘SQLDA+’
  • SQLDABC – Contains the length of the SQLDA, equal to SQLN*44+16
  • SQLN – Contains the total number of occurrences of SQLVAR
  • SQLD – Indicates the number of columns described by occurrences of SQLVAR
  • SQLVAR – Contains the information of each SQl statement, it is defined as an array.
  • SQLVAR contains data type of the column, length, pointer to the actual data and name of that SQL.

Ex:

03 WW-SQLVAR OCCURS 10 TIMES.
   05 WW-SQLTYPE PIC S9(4) COMP.
   05 WW-SQLLEN PIC S9(4) COMP.
   05 WW-SQLDATA POINTER.
   05 WW-SQLIND POINTER.
   05 WW-SQLNAME PIC X(32).

 

To get basic details on Dynamic Queries please refer http://www.techtricky.com/dynamic-sql-in-db2-cobol/

Comment if you have any concerns on this topic.

Add a Comment

Your email address will not be published. Required fields are marked *

Close Bitnami banner