If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > passing variables to sqlplus scripts

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-03, 14:32
pdt pdt is offline
Registered User
 
Join Date: Nov 2002
Posts: 8
Smile passing variables to sqlplus scripts

Hi,

I am loading some tables using a batch file calling sqlplus scripts.
I would like to pass variables into the sqlplus script ( key ids) so
that the sqlplus script can pass the variables into stored procedure calls.
How do I do this?

example of what I am currently doing

batch file call:
sqlplus user/password@database @History_Load_Account_Trans_Daily

where @History_Load_Account_Trans_Daily is the name of the sqlplus script. I would like to pass in @History_Load_Account_Trans_Daily 12345, 999999. or other numbers or values.

so I can do this in the sqlplus script:

execute pkg_acct_serv_acct_trans_hist.load_daily_account_t rans_id (12345, 999999);

Thank you
Reply With Quote
  #2 (permalink)  
Old 01-16-03, 14:41
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: passing variables to sqlplus scripts

The call would be:

sqlplus user/password@database @History_Load_Account_Trans_Daily 12345 999999

Then in the script:

execute pkg_acct_serv_acct_trans_hist.load_daily_account_t rans_id (&1, &2);

Note: for a VARCHAR2 value you would write '&1' instead of &1
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 01-17-03, 10:09
pdt pdt is offline
Registered User
 
Join Date: Nov 2002
Posts: 8
Smile

Thank you for the answer Andrew.
Paul
Reply With Quote
  #4 (permalink)  
Old 01-20-03, 13:18
clio_usa clio_usa is offline
Registered User
 
Join Date: Apr 2002
Location: California, USA
Posts: 482
Smile

You can do it also interactively with ACCEPT command in SQL*Plus:

SET VERIFY OFF

ACCEPT par1 prompt "ENTER PARAMETER #1: "

ACCEPT par2 prompt "ENTER PARAMETER #2: "

execute pkg_acct_serv_acct_trans_hist.load_daily_account_t rans_id ( &&par1, &&par2);



Hope that helps,

clio_usa
OCP - DBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On