Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: variables in sql-statements
"Simon Schrammel" <ssh_at_tetrag.ch> wrote in message news:<dcFV6.101$io1.504326_at_news>...
> Hello
>
> I am creating a script which uses variables. I store the table-names in
> these variables and I need to uses these variables in sql-statements. How
> does this work in orcacle?
There are several ways to do this, depending on what exactly you're trying to do. For example, to simply write a script (an SQL*PLUS script) to do this you could write something like:
define tab='emp';
define col='deptno';
select &col from scott.&tab;
You could set the substitution variables (tab and col) in the script and use them inside a PL/SQL block.
You could execute a dynamic SQL statement.
It just depends on how you, ultimately, you intend to use the script.
Jim Lyons Received on Wed Jun 13 2001 - 10:50:02 CDT