Oracle Problem 1: Please Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • singhjih

    Oracle Problem 1: Please Help


    Hi Everyone,

    This is my problem;

    *PROBLEM 1:* I need to create a table called *INSTRUCTOR_NEW * with al
    of the information from *INSTRUCTOR* table. Add a column to th
    instructor table called *SALARY* which should be a number with
    decimal places. Add a constraint to the *INSTRUCTOR_NEW * table calle
    *inst_max_sal* that stipulates that no instructor can have a salar
    greater than $3000(three thousand dollars) (this is a weekly salary).


    Code
    -------------------

    CREATE TABLE instructor_new AS
    SELECT *
    FROM instructor;

    ALTER TABLE instructor_new
    ADD (salary NUMBER(4,2)
    CONSTRAINT inst_max_sal
    CHECK (salary >= 0
    AND salary < 3000));
    /

    -------------------

    I used the code above however the problem I'm having is identifying th
    salary as a weekly salary. *How do I write that the MAX salary i
    $3000.00 per week in SQL?
    *


    -
    singhji
    -----------------------------------------------------------------------
    Posted via http://www.webservertalk.co
    -----------------------------------------------------------------------
    View this thread: http://www.webservertalk.com/message173341.htm


  • Daniel Roy

    #2
    Re: Oracle Problem 1: Please Help

    In addition to doing your homework, do we also have to pay portion of
    your tuition fees?

    Daniel

    Comment

    • Dave

      #3
      Re: Oracle Problem 1: Please Help

      singhjih <singhjih.14a3a 5@mail.webserve rtalk.comwrote in message news:<singhjih. 14a3a5@mail.web servertalk.com> ...

      You do not specify what the INSTRUCTOR table looks like, so it is
      difficult to help you. Why don't you include all the details?

      Based on what you are saying, I am assuming you need an aggregate
      function to enforce your constraint. If so, I think you will need to
      use a before insert trigger on the table rather than a simple check
      constraint, and inside the trigger, run the aggregate query to
      determine whether or not the constraint is violated or not.

      Dave
      Hi Everyone,
      >
      This is my problem;
      >
      *PROBLEM 1:* I need to create a table called *INSTRUCTOR_NEW * with all
      of the information from *INSTRUCTOR* table. Add a column to the
      instructor table called *SALARY* which should be a number with 2
      decimal places. Add a constraint to the *INSTRUCTOR_NEW * table called
      *inst_max_sal* that stipulates that no instructor can have a salary
      greater than $3000(three thousand dollars) (this is a weekly salary).
      >
      >
      Code:
      --------------------
      >
      CREATE TABLE instructor_new AS
      SELECT *
      FROM instructor;
      >
      ALTER TABLE instructor_new
      ADD (salary NUMBER(4,2)
      CONSTRAINT inst_max_sal
      CHECK (salary >= 0
      AND salary < 3000));
      /
      >
      --------------------
      >
      I used the code above however the problem I'm having is identifying the
      salary as a weekly salary. *How do I write that the MAX salary is
      $3000.00 per week in SQL?
      *

      Comment

      Working...