Re: Variables in SELECT

From: James Hedman <t1jamesh_at_tekig7.pen.tek.com>
Date: 25 Feb 1995 02:21:49 GMT
Message-ID: <3im47t$t7f_at_tekadm1.cse.tek.com>


In article <3iktmo$8i1_at_usenet.INS.CWRU.Edu>, fn649_at_cleveland.Freenet.Edu (Jeff Houston) writes:
>
> Is it possible to use a parameter input to a procedure to
> provide a table name for a PL/QSL select statement? The
> following statement does not substitute for the table name,
> but prompts the user for input during compilation:
>
> SELECT COUNT(*) FROM '&1'
> WHERE deptno IS NOT NULL
>
> Assigning the parameter to a variable, and using the variable
> in the above statement did not work either. Any thoughts?

Are you sure that is PL/SQL? It looks like SQL*Plus to me and will work just fine WITHOUT the quotes as long as the first parameter is a valid table name.

For SQL*Plus try:

select count(*) from &1;

For an anonymous PL/SQL block try:

declare
  result number(9);
begin
  select count(*) into result from &1;
end;
/   Received on Sat Feb 25 1995 - 03:21:49 CET

Original text of this message