GET DESCRIPTOR
Description
- 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 [, ... ]
Parameters
- descriptor_name
Descriptor name.
- descriptor_header_item
Header item 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
Information item about a column to be retrieved.
- cvariable
A host variable that will receive the data retrieved from the descriptor area.
Examples
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 = 0; char d_data[1024] = {0}; int d_returned_octet_length = 0; EXEC SQL END DECLARE SECTION; /* Create testdb in advance. */ EXEC SQL CONNECT TO test; 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
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