Results 1 to 2 of 2

Thread: Trigger Helping

  1. #1
    Join Date
    Apr 2006
    Posts
    1

    Question Unanswered: Trigger Helping

    I write a trigger
    Require Whenever an employee is given a raise, the manager’s salary must be increased to be at least as much.

    CREATE TABLE Employees(
    e# NUMBER(6) NOT NULL, /* Employee number */
    ename VARCHAR(30) NOT NULL, /* Employee name */
    age NUMBER(3) NOT NULL, /* Employee age */
    salary NUMBER(8,2) NOT NULL, /* Employee salary */
    CONSTRAINT Employees_PKey PRIMARY KEY (e#)
    );

    INSERT INTO Employees VALUES( 210001, 'James Bond', 35, 55000);
    INSERT INTO Employees VALUES( 210002, 'David Steel', 40, 45000);
    INSERT INTO Employees VALUES( 210003, 'Mark Polor', 25, 63000 );
    INSERT INTO Employees VALUES( 210004, 'Robin Hood', 28, 24000 );
    INSERT INTO Employees VALUES( 210005, 'Peter Bean', 33, 30000 );
    INSERT INTO Employees VALUES( 210006, 'Luke Skywalker', 20, 38000 );
    INSERT INTO Employees VALUES( 210007, 'Michael Collins', 20, 67000 );
    INSERT INTO Employees VALUES( 210008, 'Gray Hoffman', 20, 75000 );
    INSERT INTO Employees VALUES( 210009, 'Joseph Staunton', 20, 12000 );
    INSERT INTO Employees VALUES( 210010, 'Stephen Finch', 20, 22000 );


    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ */
    /* Department table */
    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ */

    CREATE TABLE Department(
    d# NUMBER(3) NOT NULL, /* Department number */
    dname VARCHAR2(50) NOT NULL, /* Department name */
    budget NUMBER(10,2), /* Budget of the department */
    manager NUMBER(6), /* Manager of the department */
    CONSTRAINT Department_PKey PRIMARY KEY (d#)
    );

    INSERT INTO Department VALUES(1, 'Computer Science', 1000000, 210001);
    INSERT INTO Department VALUES(2, 'Accounting', 1200000, 210003);
    INSERT INTO Department VALUES(3, 'Engineering', 1500000, 210005);
    INSERT INTO Department VALUES(4, 'Education', 500000, 210004);
    INSERT INTO Department VALUES(5, 'Arts', 700000, 210002);


    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ */
    /* Works table */
    /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ */

    CREATE TABLE Works(
    e# NUMBER(6) NOT NULL, /* Employee number */
    d# NUMBER(3) NOT NULL, /* Department number */
    pct_time NUMBER(3) NOT NULL, /* Pecentage of time that employee works in */
    CONSTRAINT Works_fkey1 FOREIGN KEY ( e# )
    REFERENCES Employees ( e# ),
    CONSTRAINT Works_fkey2 FOREIGN KEY ( d# )
    REFERENCES Department ( d# )
    );

    INSERT INTO Works VALUES(210001, 1, 100);
    INSERT INTO Works VALUES(210002, 2, 100);
    INSERT INTO Works VALUES(210003, 3, 100);
    INSERT INTO Works VALUES(210004, 4, 100);
    INSERT INTO Works VALUES(210005, 5, 100);
    INSERT INTO Works VALUES(210006, 1, 50);
    INSERT INTO Works VALUES(210006, 5, 50);
    INSERT INTO Works VALUES(210007, 1, 80);
    INSERT INTO Works VALUES(210007, 2, 20);
    INSERT INTO Works VALUES(210008, 1, 50);
    INSERT INTO Works VALUES(210008, 3, 20);
    INSERT INTO Works VALUES(210008, 4, 30);
    INSERT INTO Works VALUES(210009, 2, 40);
    INSERT INTO Works VALUES(210009, 3, 60);
    INSERT INTO Works VALUES(210010, 1, 30);
    INSERT INTO Works VALUES(210010, 4, 60);

    How can I write?? Any one can help me

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You are in luck - somebody else in your class has already posted a question about this homework assignment here. What's more, he actually made some attempt to answer it for himself!

Posting Permissions

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