Purpose
Constructs XML documents using data that is stored in the XML collection tables that are specified by the <Xcollection> in the DAD file and inserts each XML document as a row into the result table. You can also open a cursor on the result table and fetch the result set.
To provide flexibility, dxxGenXML() also lets the user specify the maximum number of rows to be generated in the result table. This decreases the amount of time the application must wait for the results during any trial process. The stored procedure returns the number of actual rows in the table and any error information, including error codes and error messages.
To support dynamic query, dxxGenXML() takes an input parameter, override. Based on the input overrideType, the application can override the SQL_stmt for SQL mapping or the conditions in RDB_node for RDB_node mapping in the DAD file. The input parameter overrideType is used to clarify the type of the override. For details about the override parameter, see Dynamically overriding values in the DAD file.
dxxGenXML(CLOB(100K) DAD, /* input */ char(UDB_SIZE) resultTabName, /* input */ integer overrideType /* input */ varchar(1024) override, /* input */ integer maxRows, /* input */ integer numRows, /* output */ long returnCode, /* output */ varchar(1024) returnMsg) /* output */
Parameters
Table 46. dxxGenXML() parameters
Parameter | Description | IN/OUT parameter |
---|---|---|
DAD | A CLOB containing the DAD file. | IN |
resultTabName | The name of the result table, which should exist before the call. The table contains only one column of either XMLVARCHAR or XMLCLOB type. | IN |
overrideType | A flag to indicate the type of the following override
parameter:
| IN |
override | Overrides the condition in the DAD file. The input value is based
on the overrideType.
| IN |
maxRows | The maximum number of rows in the result table. | IN |
numRows | The actual number generated rows in the result table. | OUT |
returnCode | The return code from the stored procedure. | OUT |
returnMsg | The message text that is returned in case of error. | OUT |
Examples
The following example assumes that a result table is created with the name of XML_ORDER_TAB, and that the table has one column of XMLVARCHAR type.
#include "dxx.h" #include "dxxrc.h" EXEC SQL INCLUDE SQLCA; EXEC SQL BEGIN DECLARE SECTION; SQL TYPE is CLOB(100K) dad; /* DAD */ SQL TYPE is CLOB_FILE dadFile; /* dad file */ char result_tab[32]; /* name of the result table */ char override[2]; /* override, will set to NULL*/ short overrideType; /* defined in dxx.h */ short max_row; /* maximum number of rows */ short num_row; /* actual number of rows */ long returnCode; /* return error code */ char returnMsg[1024]; /* error message text */ short dad_ind; short rtab_ind; short ovtype_ind; short ov_inde; short maxrow_ind; short numrow_ind; short returnCode_ind; short returnMsg_ind; EXEC SQL END DECLARE SECTION; /* create table */ EXEC CREATE TABLE xml_order_tab (xmlorder XMLVarchar); /* read data from a file to a CLOB */ strcpy(dadfile.name,"e:\dxx\dad\litem3.dad"); dadfile.name_length = strlen("e:\dxx\dad\litem3.dad"); dadfile.file_options = SQL_FILE_READ; EXEC SQL VALUES (:dadfile) INTO :dad; strcpy(result_tab,"xml_order_tab"); override[0] = '\0'; overrideType = NO_OVERRIDE; max_row = 500; num_row = 0; returnCode = 0; msg_txt[0] = '\0'; collection_ind = 0; dad_ind = 0; rtab_ind = 0; ov_ind = -1; ovtype_ind = 0; maxrow_ind = 0; numrow_ind = -1; returnCode_ind = -1; returnMsg_ind = -1; /* Call the store procedure */ EXEC SQL CALL dxxGenXML(:dad:dad_ind; :result_tab:rtab_ind, :overrideType:ovtype_ind,:override:ov_ind, :max_row:maxrow_ind,:num_row:numrow_ind, :returnCode:returnCode_ind,:returnMsg:returnMsg_ind);