DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2000
    Hi Folks,

    Can I define a default value for a column based on a column value in another table? eg. alter table product modify location_id (default select location_id from user_listing where product.user_id = user_listing.user_id). Thanks for the help.

  2. #2
    Join Date
    Dec 2000
    Ljubljana, Slovenia
    NO, you can't.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Sep 2000
    You *might* be able to do that with a "before insert" trigger. The problem I used to always run into with triggers was the "mutating table" error, but I could usually work around it.


  4. #4
    Join Date
    Mar 2001
    macswell is right, you can do it if you use the before insert trigger. Just remember that you cannot do a select on the table that the trigger is on or even selects on that table in a roundabout way (does an insert on another table that selects from the original).

    To get the default value, the query would be like:

    select location_id
    into :new.user_id
    from user_listing
    :new.user_id = user_listing.user_id

Posting Permissions

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

Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.