Initializing a constant which is a user-defined record type
20020Apr 16 2009 — edited Apr 17 2009Hello 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