Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    34

    Unanswered: take default values if null is passed

    Hi All

    I would like to know if this possible in oracle.
    I have certain columns in a table which are mandatory(not null)
    I have default values for these columns attached

    Now ideally only when we skip these columns while insert into the table, are the default values attached to the newly inserted rows.

    But what i want is to have the default values attached to the new rows even when the insert statement is trying to insert a null value table & not raise a not null constraint


    is this possible , if yes can somebody ellaborate

    Rgrds

  2. #2
    Join Date
    Jan 2004
    Location
    Hyderabad, India
    Posts
    37
    Hi,

    If you have NOT NULL constraint on columns, then you will not be able to insert NULL values to the column. If your requirement is to insert NULL values to the column, then whats the reason to have NOT NULL constraint on the column??

    What i suggest is, just drop the NOT NULL constraint on the column, but keep the DEFAULT value.

    But i dont think its possible to insert NULL value in a NOT NULL column in anyway...
    Regards
    Suneel

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    If the column is supposed to be a mandatory one, I think it is normal to expect raising the not null constraint while inserting null into it.

    However, perhaps you could try to "intercept" raising that constraint using a database trigger. You might be happy with it. But, I also think you'll run into another Oracle "trap" - mutating table. Such a problem can be solved using PL/SQL tables.

    If you think it could help, do some research - there are examples on the Internet showing how to deal with such things.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •