Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to make a procedure return a subset of records as a single type
a_ntt
meeting a certain requirement for which I am trying to define a cursor
a_cur
, and this is the relevant code for my question:
a_t a_cur%ROWTYPE;
TYPE a_ntt IS TABLE OF a_t;
l_a a_ntt;
My database server throws PLS-00488 (invalid variable declaration object must be a type or subtype) considering variable a_t
. I would like to know why. To me it seems I have provided a type to a_t
, I would suggest ROWTYPE
does that for me, but obviously I am not getting something.
I would like to know why this error occurs, why declaring a_t
as a_cur%ROWTYPE
does not prevent this.
Just to make sure, I have resolved the issue by adding %TYPE
to the line, so TYPE a_ntt IS TABLE OF a_t%TYPE;
, but I would like to know why this is necessary.
a_t
is not a type. It is a variable whose type is a_cur%ROWTYPE
. You can't use it as a type.
a_t%TYPE
is a type though, so that works.
The syntax diagrams for the "collection variable declaration" is in the PL/SQL docs. You'll see that either you need a type, or a rowtype_attribute
which has cursor, table or view name with %ROWTYPE
attached, or a type_attribute
which is essentially a variable name with %TYPE
attached.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.