I'd like to pull a column of data in a table into a host array. In my table, DOB is an integer type. My C++ code looks like this:
EXEC SQL BEGIN DECLARE SECTION;
int birthdays[10];
EXEC SQL END DECLARE SECTION;
...//Code to connect with the database
EXEC SQL EXECUTE
DECLARE
...
BEGIN
SELECT DOB INTO :birthdays FROM DRIVER_LICENSE WHERE DL_NUMBER < 10;
END
The DOB column is of integer type, and the DL_NUMBERS in the DRIVER_LICENSE table are numbered from 0. When I try to compile this, I get the error "PLS-S-00597, expression "BIRTHDAYS' in the INTO list is of wrong type"
I can run the select if it's not in an EXECUTE. The C++ code:
EXEC SQL BEGIN DECLARE SECTION;
int birthdays[10];
EXEC SQL END DECLARE SECTION;
SQL EXEC SELECT DOB INTO :birthdays FROM DRIVER_LICENSE WHERE DL_NUMBER < 10;
Gives me the numbers from the DOB column of the DRIVER_LICENSE table.
I'm trying to use PL/SQL to consolidate a lot of SQL calls to minimize communication with the server. I can get the information into the C++ birthdays array by looping through a cursor and assign values to the birthday array elements one at a time, but that seems really inefficient.