Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Case statment in Stored Procedure
I did this test and it worked, so i must have mis-coded something in my
larger program where i encountered the problem, thanks for listening!
drop table Test_table1
CREATE TABLE Test_table1
( col_1 number NOT NULL
)
drop table Test_table2
CREATE TABLE Test_table2
( col_1 number NOT NULL, col_2 VARCHAR2(24 BYTE) NULL
insert into test_table1 values (1)
insert into test_table1 values (2)
insert into test_table1 values (3)
insert into test_table1 values (4)
insert into test_table1 values (5)
commit
INSERT INTO TEST_TABLE2 (col_1,col_2)
SELECT
t1.col_1,
case when t1.col_1 <= 3 then 'A' else 'B' end
from test_table1 t1
commit
CREATE OR REPLACE Procedure pop_t2
as
begin
INSERT INTO TEST_TABLE2 (col_1,col_2)
SELECT t1.col_1,
case when t1.col_1 < '3' then 'A'
when t1.col_1 = '3' then 'C'
else 'B'
end
from test_table1 t1;
commit;
end ;
call pop_t2()
select * from test_table2 Received on Thu Jul 14 2005 - 16:05:23 CDT