var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Fastest DECODE with EXISTS?
I have a typical SQL statement:
Insert into X
( field1, field2)
I need to get an 'Y' into field 1 if another field (FieldX) exists in another table's FIELDZ.
I typically hard code stuff using DECODE() in the select statement.
I have also used the EXISTS(Select...) to limit the number of records into a table.
What is the fastest way to accomplish the lookup and update the field?
I'm having trouble seeing the connection between DECODE and EXISTS in your example, or what either of them have to do with INSERT.
I utilize decode to "hard code" a value within the insert statement.
I sometimes utilize Exists() to limit the data inserted at the end of the insert statement.
What I would like to do is force a value into the table if one of the fields exists in another table.
I would like to accomplish this within the insert statement.
The logic would be a combination of Decode(xxx,exists()) within the insert but I know that doesnt make SQL sense.
Hope that helps out.
Perhaps CASE does what you want:
SQL> create table t1 (x varchar2(1));
SQL> insert into t1 (x) values (case when exists (select null from emp) then 'Y' else 'N' end);
1 row created.
SQL> select * from t1;