Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

%rowtype record as a parameter within a package 1

Status
Not open for further replies.

gacaccia

Technical User
Joined
May 15, 2002
Messages
258
Location
US
a few posts ago, I had asked about how to use a %rowtype record (based on a cursor) as a parameter for a procedure. the final example of how to do this was something like...

Code:
cursor c is select * from t;
rec c%rowtype;

procedure pr(r c%rowtype) is
begin
    null;
end;

this solution worked fine until I tried to implement it within the context of a package. I get a compilation error message.

for example...

Code:
package pk is
    pr(r c%rowtype);
end;

package body pk is
  cursor c is select * from t;
  rec c%rowtype;

  procedure pr(r c%rowtype) is
  begin
      null;
  end;
end;

how do I pass the variable "rec" into a procedure within the context of a package?

 
Glenn,

Just "elevate" the definition of "cursor c" to the Package Header:
Code:
SQL> create or replace package pk is
  2      cursor c is select * from t;
  3      rec c%rowtype;
  4      procedure pr(r c%rowtype);
  5  end;
  6  /

Package created.

SQL> create or replace package body pk is
  2    procedure pr(r c%rowtype) is
  3    begin
  4        null;
  5    end;
  6  end;
  7  /

Package body created.
Let us know if this resolves your need.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top