Monday, May 24, 2010

Simple Insert in Oracle with Case Statement







Below is a sample code for insert statement here I have used "case statement" in select and "not exists" in where clause..

insert into table1 t1 (field1,field2)
(select field1, case when field2 = ' ' then field2
else to_char(to_number(field2)
end
from table2 t2
where t2.field1 = t1. field1
and not exists (select 1
from table3 t3
where t3.field1 = t2.field1));

please don't forget to visit: http://www.lendmyspace.com


No comments:

Post a Comment