View Single Post

   
  #4 (permalink)  
Old 04-08-2008, 11:14 AM
Sybrand Bakker
 
Posts: n/a
Default Re: Macro Substitution Variables in Oracle SQL

On 25 Aug 2006 08:03:14 -0700, "Andreww" <andrew.whittam@gmail.com>
wrote:

>Hi Sybrand - I am a bit confused...
>
>if I had the following code:
>
>select count(*)
>from tblCustomers
>where store_code='X189';
>
>How would I implement the solution?
>
>Thanks for your help.
>
>Andrew



define p_store_code = '&1'
select count(*)
from tblCustomers
where store_code = '&p_store_code'

or

variable p_store_code varchar2(4);
begin
_store_code := '&1';
end;
/
select count(*)
from tblcustomers
where store_code = _store_code

in both cases you would call the script with
<script name> <space> 'X189'

If you don't provide the parameter you will be prompted.

Could you please refrain from top posting?

--
Sybrand Bakker, Senior Oracle DBA
Reply With Quote