Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Update question
Looks like there are two solutions
1 Use decode like this:
update <some table>
department_col = decode(department_col,'AA','OAA','VC','VCA') /*
and so on */
;
2 in sqlplus write a script
define old_val = &1
define new_val = &2
update <some table>
department_col = '&new_val'
where department_col = '&old_val'
run this script as follows
start <yourscript> AA OAA
start <yoursscript> VC VCA
and so on
Hth,
Sybrand Bakker, Oracle DBA
Paul Schattling wrote:
> Is it possible to use an 'if' in an UPDATE statement. i.e. If I have a
> column in a table called Departments and it is made up of various values
>
> (like 'AA' and 'VC') and I want to SET these to be 'OAA' and 'VCA' (not
> always the same change) do I have to run it one by one manually or can I
> update them using an IF
> statement somehow? I have about 50 different Departments to update, of
> which there are about 95 records for each.
>
> Thanks in advance!
Received on Mon Oct 12 1998 - 00:00:00 CDT