Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    4

    Unanswered: command to reference another table

    Hi all,

    I am new to this site and I hope anyone out there can help me. I was tasked to change the constraints of my existing table. Lets call it table1. This table has an attribute that needs to take the value of another attribute of another table ( let's call it tables2) and that attribute must satisfy a certain expression ( I suppose I can isolate it by using the select statement ).

    Anyone know how to get this done.

    Please advice.

    Thanks and appreciated.

  2. #2
    Join Date
    Jun 2003
    Posts
    269
    Quote Originally Posted by ericwi
    Hi all,

    I am new to this site and I hope anyone out there can help me. I was tasked to change the constraints of my existing table. Lets call it table1. This table has an attribute that needs to take the value of another attribute of another table ( let's call it tables2) and that attribute must satisfy a certain expression ( I suppose I can isolate it by using the select statement ).

    Anyone know how to get this done.

    Please advice.

    Thanks and appreciated.
    u have given very little information.Read the sticky (first post on this forum) first
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    This sounds like homework to me. If it is, please post the URL for the assignment, or at least scan the page so we can see the "whole tamale" and solve the problem once instead of giving you what you asked for, but not what the teacher wants. If this is not homework, please see How to ask a question to get quick and correct answers? in this forums FAQ.

    -PatP

  4. #4
    Join Date
    May 2005
    Posts
    4
    Hi all,

    I have yet to try this statement:-

    alter table coursefee
    add check ( course_code = course.course_code and
    course.quota is not null );

    coursefee :- table1
    course_code :- PK of table1
    course :- table2
    course.course_code :- PK of table2
    course.quota :- another attribute of table2

    My intention is set a constraint on table1 where there will be an error if there is an insert on table2 whereby quota ( from table1) is null.


    Is this plausible?

    Sorry to trouble all again.

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I don't think you can reference another table in a CHECK CONSTRAINT. I suspect that you'll need to use a trigger if you really want to do this, but I wouldn't recommend doing it, for many reasons.

    -PatP

Posting Permissions

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