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

Home -> Community -> Usenet -> c.d.o.tools -> Re: variables in sql-statements

Re: variables in sql-statements

From: Jim Lyons <jlyons_at_weblyons.com>
Date: 13 Jun 2001 08:50:02 -0700
Message-ID: <e67857c9.0106130750.2db46881@posting.google.com>

"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

Original text of this message

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