I need to have an EXECUTE IMMEDIATE return its results into an table type (AS TABLE OF)
If the execute immediate returns a single value i am able to save the result using "INTO somevariable"
But, my execute immediate will return a multi column table and no amount of googling have help me figure it out!
First I create the types
CREATE OR REPLACE TYPE T_VALIDITY_RECORD AS OBJECT (
TIME_COL DATE,
VALUE_COL NUMBER
);
/
CREATE OR REPLACE TYPE T_VALIDITY_TABLE AS TABLE OF T_VALIDITY_RECORD;
/
Then I attempt the code
DECLARE
RET_TABLE T_VALIDITY_TABLE;
BEGIN
EXECUTE IMMEDIATE 'SELECT my_date,
my_numbers
FROM my_table
WHERE somthing = somthingelse' INTO RET_TABLE;
END;
This is just a really simplified example, the real code does (will do other things)
I've tried various things like BULK COLLECT INTO etc but can't seem to get it working.
I am getting the following error:
Error report
ORA-00932: inconsistent datatypes: expected - got -
ORA-06512: at line 5
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action: