By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,504 Members | 1,903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,504 IT Pros & Developers. It's quick & easy.

Oracle Problem 1: Please Help

P: n/a

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
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In addition to doing your homework, do we also have to pay portion of
your tuition fees?

Daniel
Jul 19 '05 #2

P: n/a
singhjih <si*************@mail.webservertalk.com> wrote in message news:<si*************@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?
*

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.