[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

User defined records and how to declare in spec as well as body

If I have a record declared in the body of my package for the purposes of passing records instead of variables as parameters, must I also declare the record in the spec. I seem to be getting an error that makes me believe that I need to declare it in the spec as well as the body.

The error was PLS-00201. params_rec must be declared

my record in the body is this:
TYPE PARAMS_REC IS RECORD(
                             P_SCHEMA VARCHAR2(4000)
                            ,P_TABLENAME VARCHAR2(4000)
                            ,P_QUERY VARCHAR2(4000)
                            ,P_LOGGING_Y_N VARCHAR2(1)
                            ,P_COMPRESS_Y_N VARCHAR2(1)
                            ,P_TABLESPACE VARCHAR2(4000));

Open in new window


must it also go in the spec? Things don't need to be declared in the spec unless I want them public right?

This is from the SPEC and is the procedure I want to pass the record variables to:
PROCEDURE DROP_TABLES
              (
                            /*P_SCHEMA VARCHAR2
                           ,P_TABLENAME VARCHAR2*/
                          P_PARAMS_REC PARAMS_REC; --THIS ISN'T WORKING

              ); --DROPS PRE-EXISTING TABLES

Open in new window

0
Mark_Co
Asked:
Mark_Co
  • 5
  • 4
5 Solutions
 
sdstuberCommented:
since the procedure and it's params_rec parameter are defined in the spec,  the record type itself must also be defined in the spec.  

the procedure's declaration is what is requiring it to be public.



Without the type being in the spec,  the procedure declaration doesn't make sense.
What is "params_rec" within the scope of the spec, if it's hidden in the body?
0
 
Mark_CoAuthor Commented:
"since the procedure and it's params_rec parameter are defined in the spec" did you mean body?
0
 
sdstuberCommented:
no I meant spec

>>> This is from the SPEC and is the procedure I want to pass the record variables to:


You declared the procedure in the SPEC, the procedure requires "params_rec", so in order for that declaration to be valid, everything in the declaration must be known.


Once the record type is declared in the spec, take it out of the body
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Mark_CoAuthor Commented:
OH i think i see what you mean. So i remove it from the body altogether, and just declare it in the spec only?
0
 
sdstuberCommented:
Another way to look at it.


PROCEDURE my_proc(p_my_parameter IN my_secret_type);



can you invoke this procedure?

No,  you don't know what my_secret_type  is.
You can't declare a variable to be of that type because it's a secret, hidden in the body.

That's effectively what your current spec is saying.
0
 
sdstuberCommented:
>>> OH i think i see what you mean. So i remove it from the body altogether, and just declare it in the spec only?

yes
0
 
Mark_CoAuthor Commented:
...and if I chose to not declare the procedure at all in the spec, then I could leave the record defined in the body and I should be ok?
0
 
sdstuberCommented:
yes, as long as you don't have any other public references to it, it can stay hidden in the body
0
 
Mark_CoAuthor Commented:
Great! I appreciate you helping me understand that
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now