Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable in UPDATE statement 1

Status
Not open for further replies.

cwsstins

MIS
Aug 10, 2004
412
US
I have a script that I run in Oracle SQL*Plus. It updates a flag to 'T' if the customer's account number is like "one of these hard-coded numbers". Each customer account is 6-digits plus other digits that designate regional locations, etc. So my script looks like this:

Code:
UPDATE tbl
SET FLAG = 'T'
WHERE
   ACCTNO like '002476%'
OR ACCTNO like '003748%'
OR ACCTNO like '054379%'

... except that there are over 100 accounts and that number will grow. Rather than updating the script each time a new account needs to be added, can I change the script to something like this:

Code:
UPDATE tbl
SET FLAG = 'T'
WHERE
   ACCTNO like 'VarAcctNo'

...where VarAcctNo is a variable stored in a .txt file or some config file? That way, I could update the config file as needed and never touch the script.

I'm thinking there must be a way to do this, but I'm not very familiar with Oracle programming.

dstinsman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top