GET DESCRIPTOR
Function
- Retrieves the descriptor "header" items, which applies to the result set in its entirety.
- Retrieves information about a particular column, requiring the column number as additional parameter.
Syntax
GET DESCRIPTOR descriptor_name VALUE column_number :cvariable = descriptor_item [, ... ] GET DESCRIPTOR descriptor_name:cvariable = descriptor_header_item [, ... ]
Parameter Description
- descriptor_name
SQL descriptor name.
- descriptor_header_item
Identifies which header item is to be retrieved. Currently, only COUNT that is used to obtain the number of columns in the result set is supported.
- column_number
Number of the column about which information is to be retrieved. The count starts at 1.
- descriptor_item
Identifies which information item about a column is to be retrieved.
- cvariable
A host variable that will receive the data retrieved from the descriptor area.
Example
EXEC SQL GET DESCRIPTOR d :d_count = COUNT;
EXEC SQL GET DESCRIPTOR d VALUE 1 :d_returned_octet_length = RETURNED_OCTET_LENGTH;
EXEC SQL GET DESCRIPTOR d VALUE 2 :d_data = DATA;
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { EXEC SQL BEGIN DECLARE SECTION; int d_count; char d_data[1024]; int d_returned_octet_length; EXEC SQL END DECLARE SECTION; EXEC SQL CONNECT TO testdb AS con1 USER testuser; EXEC SQL SELECT pg_catalog.set_config('search_path', '', false); EXEC SQL COMMIT; EXEC SQL ALLOCATE DESCRIPTOR d; /* Declare and open a cursor, and allocate a descriptor to the cursor. */ EXEC SQL DECLARE cur CURSOR FOR SELECT current_database(); EXEC SQL OPEN cur; EXEC SQL FETCH NEXT FROM cur INTO SQL DESCRIPTOR d; /* Obtain the total number of columns. */ EXEC SQL GET DESCRIPTOR d :d_count = COUNT; printf("d_count = %d\n", d_count); /* Obtain the length of a returned column. */ EXEC SQL GET DESCRIPTOR d VALUE 1 :d_returned_octet_length = RETURNED_OCTET_LENGTH; printf("d_returned_octet_length = %d\n", d_returned_octet_length); /* Fetch the returned column as a string. */ EXEC SQL GET DESCRIPTOR d VALUE 1 :d_data = DATA; printf("d_data = %s\n", d_data); /* Closed */ EXEC SQL CLOSE cur; EXEC SQL COMMIT; EXEC SQL DEALLOCATE DESCRIPTOR d; EXEC SQL DISCONNECT ALL; return 0; }
d_count = 1 d_returned_octet_length = 6 d_data = testdb
Helpful Links
ALLOCATE DESCRIPTOR, DEALLOCATE DESCRIPTOR, and SET DESCRIPTOR
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot