Purpose
Enables the same DAD file to be used for both composition and decomposition. The stored procedure dxxRetrieveXML() also serves as a means for retrieving decomposed XML documents. As input, dxxRetrieveXML() takes a buffer containing the DAD file, the name of the created result table, and the maximum number of rows to be returned. It returns a result set of the result table, the actual number of rows in the result set, an error code, and message text.
To support dynamic query, dxxRetrieveXML() 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.
The requirements of the DAD file for dxxRetrieveXML() are the same as the requirements for dxxGenXML(). The only difference is that the DAD is not an input parameter for dxxRetrieveXML(), but it is the name of an enabled XML collection.
dxxRetrieveXML(char(UDB_SIZE) collectionName, /* 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 47. dxxRetrieveXML() parameters
Parameter | Description | IN/OUT parameter |
---|---|---|
collectionName | The name of an enabled XML collection. | 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 of 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 is an example of a call to dxxRetrieveXML(). In this example, a result table is created with the name of XML_ORDER_TAB, and it has one column of XMLVARCHAR type.
#include "dxx.h" #include "dxxrc.h" EXEC SQL INCLUDE SQLCA; EXEC SQL BEGIN DECLARE SECTION; char collection[32]; /* dad buffer */ 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 dadbuf_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 SQL CREATE TABLE xml_order_tab (xmlorder XMLVarchar); /* initialize host variable and indicators */ strcpy(collection,"sales_ord"); 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; 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 dxxRetrieve(:collection:collection_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);