Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> problem - any way to declare 'dynamic' record in PL/SQL?
I want to set up a table of records in a PL/SQL procedure using a
relation passed in as a parameter which is unknown in terms of structure
(i.e. could have any number and type of columns, primary key attributes,
etc.). It would look something like:
PROCEDURE xxxx (relation_name IN VARCHAR2)
IS
...
BEGIN
.. (set up and open dynamic cursor on relation with relation_name,
read in records from relation, store them in the table of records) END; I can set up the cursor, but don't want to hardcode the type/length of local variables I'm using to store the incoming data from the cursor. In other words, the problem is that I need a record type to store each row coming in from the table, and I don't know the structure as it varies with different relations sent to the procedure. Similarly, I can't declare a table type as I don't know the record type.
One possible solution would be to set up a record of all text/VARCHAR2 attributes, with some maximum number of attributes, and convert all attributes of the incoming relation to text. I could also store each attribute's type and length. This seems awkward and time-consuming.
Is there any other way of declaring a record type 'dynamically' in a procedure based on a relation coming in as a parameter? Any ideas are appreciated.
Thanks,
--
* * * * * * * * * * * * * * * *