Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to pass a record to a Procedure

Re: How to pass a record to a Procedure

From: Patrick van Zweden <newsspam_at_vanzweden.org>
Date: Tue, 14 Dec 2004 11:18:52 +0100
Message-ID: <4xu5zne34skh$.9bd7tarv8dzb$.dlg@40tude.net>


On 16 Nov 2004 12:06:45 -0800, Keith wrote:

> I have a very large program (2000+ lines) and I want to try to break
> it down into smaller pieces, make it more modular. I have a cursor
> with 80 fields. While in the cursor loop, I want to call a procedure
> and pass the whole cursor record. It will do some processing on the
> record and then return the record to the calling procedure so that the
> updated values can be used. How can I do this?
>

Use a procedure that takes a %rowtype of the cursor and modifies that. Sample procedure:

CREATE PROCEDURE xx_patrick_modproc(p_row IN OUT xx_patrick_test%ROWTYPE) AS
BEGIN
  p_row.name := 'modified';
END; xx_patrick_test is a small table, but also could be a cursor consisting of just one attribute (name).

You call it like this:

declare
begin
  for rec1 in (select * from xx_patrick_test) loop     dbms_output.put_line('Before:'||rec1.name);     xx_patrick_modproc(rec1);
    dbms_output.put_line('After:'||rec1.name)   end loop;
end;

Anyway you might already found an answer, because i realize this thread is already almost a month old. Anyway, should have realized before starting to type ;)

Patrick Received on Tue Dec 14 2004 - 04:18:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US