Greetings,
I have a question, Is it possible to insert a value and
refer to that value in the same query?
What I mean is suppose in a table there are two fields. I insert the
value into the first field and the second value has to be inserted
based on first field.
eg: If first field is inserted as 1 then the second field decides as
follows
CASE WHEN first_field=1 THEN 1 ELSE 2 END
I have tried this, but i think I was not able to frame it properly. Can
anyone tell me how to do this?
TIA
Rama Shankar - 27 Feb 2006 08:54 GMT
hi,
you can achieve it using row level before insert trigger.
pls send some details ....
pankaj_wolfhunter@yahoo.co.in - 27 Feb 2006 10:51 GMT
Thanks for the reply Rama, but in our case we dont have any option for
using any triggers.
I mean we have to just use a query in which a value has to be inserted
based on the value inserted in the previous column.
About details, we have this table which has several columns. I have to
insert a value into a column based on a value of another column which I
inserted previously in the same query.
eg: If the columns are like Id and say salary. I am inserting a value
into column Id say 1 and then i want to check the values in the Id
column before i start inserting values in salary column.
I hope i am making myself clear.
TIA
Carlos - 27 Feb 2006 15:03 GMT
You should provide the 'cooked' value using a view and removing it from
the base table. If one column depends on another, then this is not 2FN.
IMHO.
Cheers.
Carlos.
pankaj_wolfhunter@yahoo.co.in - 28 Feb 2006 04:16 GMT
Thanks Carlos. Thanks All. I got what I wanted. thanks again.