Re: Oracle Problem 1: Please Help

From: Dave <davidr212000_at_yahoo.com>
Date: 6 Apr 2004 08:05:40 -0700
Message-ID: <5e092a4e.0404060705.4f0813a1_at_posting.google.com>


singhjih <singhjih.14a3a5_at_mail.webservertalk.com> wrote in message news:<singhjih.14a3a5_at_mail.webservertalk.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?
> *
Received on Tue Apr 06 2004 - 17:05:40 CEST

Original text of this message