DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Another constraint question...

  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Another constraint question...

    I need to do a table level constraint that does...

    in the acct table...if acct_type is "1" then acct_bal must be > 0, if acc_type is "2" then acct_bal must be > 100, etc..

    All the fields are within the same table.

    Thanks,
    Erik

  2. #2
    Join Date
    Nov 2000
    Location
    Israel
    Posts
    268
    write a trigger before insert for each row
    It is better to ask and appear ignorant, than to remain silent and remain ignorant.

    Oracle OCP DBA 9i,
    C++, Java developer

  3. #3
    Join Date
    Nov 2003
    Posts
    5
    I am not allowed to use a trigger for this part...this is a class assignment. I found out today that my entire class is stuck on the same part.

    Thanks,
    Erik

  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Code:
    ALTER TABLE my_table ADD CONSTRAINT check_acct_bal
    CHECK (acct_type = '1' AND act_bal > 0
           OR
           acct_type = '2' AND act_bal > 100
           OR
           etc....
          );
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

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