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

Home -> Community -> Usenet -> c.d.o.server -> Re: using table pointers in select?

Re: using table pointers in select?

From: sybrandb <sybrandb_at_gmail.com>
Date: Thu, 09 Aug 2007 03:34:07 -0700
Message-ID: <1186655647.193925.128390@22g2000hsm.googlegroups.com>


On Aug 9, 12:09 pm, "aksel.schmidt" <axl.schm..._at_gmail.com> wrote:
> hi all
>
> is it possible to use a 'pointer' like reference to a table?
> i want to write a function that should select from a table that is not
> known at compile time (but referenced in argument list)
>
> like:
> CREATE OR REPLACE FUNCTION "TEST"."DUMTEST" (tablename in varchar)
> return number
> is
> returnValue number;
> CURSOR c1
> IS (SELECT count(*) from all_objects); -- here i want to
> use the 'tablename' argument instead of 'all_objects' which is only
> here for compilation right now
> begin
> open c1;
> fetch c1 into returnValue;
> if c1%notfound then
> returnValue:=0;
> end if;
> close c1;
> RETURN returnValue;
> end;
>
> i can resolve the object id for the table using the 'all_objects' view
> - but how can i make this reference into a table to select from?
>
> thanks!
>
> /aksel

Look up 'Dynamic SQL' in your PL/SQL documentation. Note: Dynamic SQL is parsed at runtime. Static SQL is parsed at compile time.
Your function will potentially turn the app into an unscalable one.

--
Sybrand Bakker
Senior Oracle DBA
Received on Thu Aug 09 2007 - 05:34:07 CDT

Original text of this message

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