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: owner name as parameter in a stored proc?dure

Re: owner name as parameter in a stored proc?dure

From: andrewst <member14183_at_dbforums.com>
Date: Wed, 30 Apr 2003 12:26:12 +0000
Message-ID: <2824152.1051705572@dbforums.com>

Originally posted by Ferret
> Hello,
>
> I would like to pass the name on a owner as parameter in a stored
> procedure written in PL/SQL. How can I do that.
>
> Thanks for your help
>
> Pascal Ferret.

PROCEDURE p ( p_owner VARCHAR2 ) IS ...

Now what? Probably you want to SELECT from some table owned by that owner, or something like that. You need to use dynamic SQL. For example:

PROCEDURE p ( p_owner VARCHAR2 ) IS
  v_count NUMBER;
BEGIN
  EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM '||p_owner||'.emp' INTO   v_count;
  DBMS_OUTPUT.PUT_LINE(p_owner||'.emp contains '||v_count||' rows'); END;
/

SQL> exec p('TANDREWS')
TANDREWS.emp contains 14 rows

PL/SQL procedure successfully completed.

--
Posted via http://dbforums.com
Received on Wed Apr 30 2003 - 07:26:12 CDT

Original text of this message

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