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

Home -> Community -> Usenet -> c.d.o.misc -> Re: UPDATE QUERY QUESTION

Re: UPDATE QUERY QUESTION

From: Galen Boyer <gboyergolf_at_yahoo.com>
Date: 07 Apr 2000 15:14:45 -0400
Message-ID: <uvh1t910a.fsf@yahoo.com>


"Jon" <J_S_Finley_at_yahoo.com> writes:

The following worked for me:
create table tst (id1 number(38,0), fld1 char(1));

insert into tst values (1,'A');
insert into tst values (1,'B');
insert into tst values (1,'C');

update tst set fld1 = (decode (fld1,'A','X','B','Y','C','Z')); select * from tst;

      ID1 FL
--------- --

	1 X
	1 Y
	1 Z

> I need to do a single update query with the following:
>
> UPDATE sections SET PHASE = 'A' WHERE CONDUCTOR = '2-2, 2-2';
> UPDATE sections SET PHASE = 'AB' WHERE CONDUCTOR = '2-3';
> UPDATE sections SET PHASE = 'ABC' WHERE CONDUCTOR = '2-4';
> UPDATE sections SET PHASE = 'ABC' WHERE CONDUCTOR = '4-2, 6-2';
> UPDATE sections SET PHASE = 'ABC' WHERE CONDUCTOR = '4-2-, 6-2';
> UPDATE sections SET PHASE = 'AB' WHERE CONDUCTOR = '4-3';
> UPDATE sections SET PHASE = 'ABC' WHERE CONDUCTOR = '4/0-3, 2/0-1';
> UPDATE sections SET PHASE = 'A' WHERE CONDUCTOR = '6-1, 4-1';
> UPDATE sections SET PHASE = 'A' WHERE CONDUCTOR = '6-2';
> UPDATE sections SET PHASE = 'ABC' WHERE CONDUCTOR = '6-2, 4-2';
>
> I'm new to Oracle can anyone help me get this done with one query.
>
> This is how I do it in ACCESS
>
> UPDATE SECTIONS SET SECTIONS.PHASE =
> IIf([conductor]="2-4","ABC",IIf([conductor]="4-2,
> 6-2","ABC",IIf([conductor]="4-3","ABC",IIf([conductor]="4/0-3,
> 2/0-","ABC",IIf([conductor]="6-1,
> 4-1","A",IIf([conductor]="6-2","A",IIf([conductor]="6-2,
> 4-2","ABC",[PHASE])))))));
>
> I thought about decode would that work or is there something real simple
> that I am missing here. I apologize for my ignorance I'm very new to this
> program.
> Thanks
> -Jon
Received on Fri Apr 07 2000 - 14:14:45 CDT

Original text of this message

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