Inserting and Referencing In the same Query - 02-26-2006 , 11:47 PM
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
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?
Re: Inserting and Referencing In the same Query - 02-27-2006 , 04:51 AM
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.
Re: Inserting and Referencing In the same Query - 02-27-2006 , 09:03 AM
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.