Home » RDBMS Server » Server Administration » How to set a conditional DEFAULT value to a column?
How to set a conditional DEFAULT value to a column? [message #375098] Wed, 25 July 2001 21:49 Go to next message
Priya Rajkumar
Messages: 5
Registered: March 2001
Junior Member
How to set a conditional DEFAULT value to a column?

Hi all,

I am trying to set a DEFAULT value to a column based on a condition.
For Example,

I have a table TEST with col1 VARCHAR2(10) and col2 VARCHAR2(10) as its columns. I would like to DEFAULT a value let's say 'X' to col2 based on the value in col1. If SUBSTR(col1, 1, 2) = '12' then DEFAULT the col2 to 'X' else NULL.

Is this possible? I am using Oracle 8.0.6 on Unix.

Priya
Thanks !!! Re: How to set a conditional DEFAULT value to a column? [message #375099 is a reply to message #375098] Wed, 25 July 2001 23:56 Go to previous messageGo to next message
Priya Rajkumar
Messages: 5
Registered: March 2001
Junior Member
Hi,

Thankyou very much. I have changed my thought of implementing the same, using a Trigger. I knew this but thougtht if there is a tricky way to achieve it using DEFAULT/Constraint clause.

Priya
Re: How to set a conditional DEFAULT value to a column? [message #375273 is a reply to message #375098] Fri, 17 August 2001 21:06 Go to previous message
Prasad
Messages: 104
Registered: October 2000
Senior Member
Not possible!
default value can not refer to another row /column values (only sysdate ,user etc etc oracle provided env variables)
Previous Topic: Re: Summing using decode
Next Topic: Getting n max rows
Goto Forum:
  


Current Time: Tue Dec 24 11:11:18 CST 2024