Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Oracle / Oracle Server / February 2006

Tip: Looking for answers? Try searching our database.

Inserting and Referencing In the same  Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pankaj_wolfhunter@yahoo.co.in - 27 Feb 2006 05:47 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.