dbTalk Databases Forums  

Inserting and Referencing In the same Query

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Inserting and Referencing In the same Query in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pankaj_wolfhunter@yahoo.co.in
 
Posts: n/a

Default Inserting and Referencing In the same Query - 02-26-2006 , 11:47 PM






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


Reply With Quote
  #2  
Old   
Rama Shankar
 
Posts: n/a

Default Re: Inserting and Referencing In the same Query - 02-27-2006 , 02:54 AM






hi,
you can achieve it using row level before insert trigger.
pls send some details ....


Reply With Quote
  #3  
Old   
pankaj_wolfhunter@yahoo.co.in
 
Posts: n/a

Default 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.

TIA


Reply With Quote
  #4  
Old   
Carlos
 
Posts: n/a

Default 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.

IMHO.

Cheers.

Carlos.


Reply With Quote
  #5  
Old   
pankaj_wolfhunter@yahoo.co.in
 
Posts: n/a

Default Re: Inserting and Referencing In the same Query - 02-27-2006 , 10:16 PM



Thanks Carlos. Thanks All. I got what I wanted. thanks again.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.