dbTalk Databases Forums  

Help with procedure having table as a parameter

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss Help with procedure having table as a parameter in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Maikku
 
Posts: n/a

Default Help with procedure having table as a parameter - 06-08-2011 , 10:27 AM






Hi, I need to call procedure example_proc from anonymous pl/sql
block ? Is it possible ? From package it works fine but I cannot
figure out how to declare out parameter when calling from anonymous pl/
sql block.

create or replace package example_p is
type type_record is record(col1 varchar2(100),col2 varchar2(100));
type type_table is table of type_record;
procedure example_proc(par1 out type_table);
procedure example_caller;
end example_p;
/

create or replace package body example_p is
procedure example_proc(par1 out type_table)
is
begin
par1:= type_table();
par1.extend();
par1(1).col1 := 'test1';
par1(1).col2 := 'test1';
par1.extend();
par1(2).col1 := 'test2';
par1(2).col2 := 'test2';
dbms_output.put_line(par1(1).col1||' '||par1(2).col2);
end;

procedure example_caller is
example_table type_table := type_table();
begin
example_proc(example_table);
dbms_output.put_line('caller :'||example_table(1).col1);
dbms_output.put_line('caller:'||example_table(2).c ol2);
end;

end example_p;
/

set serveroutput on

exec example_p.example_caller;


Byt how do I call example_p.example_proc(par_table) ?

Thanks in advance !

Maija-Leena

Reply With Quote
  #2  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: Help with procedure having table as a parameter - 06-08-2011 , 12:03 PM






Maikku wrote:
Quote:
procedure example_caller is
example_table type_table := type_table();
begin
example_proc(example_table);
dbms_output.put_line('caller :'||example_table(1).col1);
dbms_output.put_line('caller:'||example_table(2).c ol2);
end;
something like

declare
example_table example_p.type_table := example_p.type_table();
begin
example_p.example_proc(example_table);
dbms_output.put_line('caller :'||example_table(1).col1);
dbms_output.put_line('caller:'||example_table(2).c ol2);
end;
/


??

Reply With Quote
  #3  
Old   
Maikku
 
Posts: n/a

Default Re: Help with procedure having table as a parameter - 06-08-2011 , 12:16 PM



Thanks a lot !!! This was a big help for me !!
I didn't know I can use package's type with the package name in front
of it.

Maija-Leena

Reply With Quote
  #4  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: Help with procedure having table as a parameter - 06-09-2011 , 12:54 PM



Maikku wrote:
Quote:
Thanks a lot !!! This was a big help for me !!
I didn't know I can use package's type with the package name in front
of it.

Maija-Leena
you can when it is specified in the header, and not in the body (then it would be private)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.