Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Initializing a constant which is a user-defined record type

20020Apr 16 2009 — edited Apr 17 2009
Hello all,

This may be a simple question but I'm struggling with finding a solution.

The PL/SQL documentation says I can declare a constant of a previously defined record type. But how do I initialize it during declaration? Eg.

create or replace package my_package as
type my_type is record(field1 varchar2(10), field2 varchar2(10));
c_myconst constant my_type := <what???>;
end my_package;

I've tried initializing it to a function that does nothing more than return a my_type with the fields set and that works except that PL/SQL has a restriction that this function can not be in the same package as the constant, which will make my packages appear disorganized - I'd just as soon initialize the constant in-line so programmers down the line aren't wondering why I'm calling this function off alone in its own package.

Is there some syntax that will allow me to provide the values that c_myconst needs during declaration?

Thanks ,
John
This post has been answered by APC on Apr 16 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2009
Added on Apr 16 2009
17 comments
911 views