Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:27:05+00:00 2026-05-26T19:27:05+00:00

so for my university coursework, i have to create an oracle database for an

  • 0

so for my university coursework, i have to create an oracle database for an airline. (this is my first time working with oracle)

part of my requirement is to identify whether pilots are fit to fly. to do this, my employee and pilot_test tables are set up as follows :

CREATE TABLE PILOT_TEST (
  TEST_ID NUMBER(11) PRIMARY KEY,
  TEST_DATE DATE NOT NULL,
  EMPLOYEE_ID NUMBER(11) NOT NULL
);

CREATE TABLE EMPLOYEE (
  EMPLOYEE_ID NUMBER(5) PRIMARY KEY,
  FIRST_NAME VARCHAR2(15) NOT NULL,
  LAST_NAME VARCHAR2(20) NOT NULL,
  MIDDLE_NAME VARCHAR2(15) NULL,
  POSITION VARCHAR2(13) NOT NULL, /* pilot, booking clerk, maintenance staff*/
  EMPLOYED_FROM DATE NOT NULL,
  EMPLOYED_TO DATE NOT NULL,
  TELEPHONE NUMBER(11) NOT NULL,
  EMAIL VARCHAR2(40) NULL,
  ADDRESS_LINE1 VARCHAR2(20) NOT NULL,
  ADDRESS_LINE2 VARCHAR2(20) NULL,
  TOWN VARCHAR2(20) NOT NULL,
  POST_CODE VARCHAR2(9) NOT NULL,
  SALARY NUMBER(6,2) NOT NULL,
  STATUS VARCHAR2(16) NOT NULL /*working, on leave, contract expired, fired*/
);

whenever a new flight is added to the system, i use a trigger to check whether the staff allocated to fly the plane is actually a pilot.
into this trigger i would like to check that if he IS a pilot, then whether his last TEST_DATE is less than 6 months old or not. any ideas on how this could be done?

my current trigger looks like this

CREATE OR REPLACE TRIGGER CHECK_PILOT_ALLOCATION
BEFORE INSERT ON FLIGHT
FOR EACH ROW
DECLARE 
    TEMP_POSITION VARCHAR2(13);
BEGIN

SELECT POSITION INTO TEMP_POSITION 
FROM EMPLOYEE
WHERE EMPLOYEE_ID = :NEW.PILOT_ID;

IF UPPER (TEMP_POSITION) <> 'PILOT' THEN
RAISE_APPLICATION_ERROR (-20001, 'Assigned employee is not a pilot');

ELSIF   
END IF;
END;
/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:27:06+00:00Added an answer on May 26, 2026 at 7:27 pm

    try

    DECLARE 
        TEMP_POSITION VARCHAR2(13);
        TEMP_TESTDATE DATE;
    BEGIN
    
    SELECT E.POSITION, 
           (SELECT MAX (TEST_DATE) 
              FROM PILOT_TEST PT 
             WHERE PT.TEST_DATE <= SYSDATE 
               AND PT.EMPLOYEE_ID = E.EMPLOYEE_ID) TEST_DATE 
      INTO TEMP_POSITION, 
           TEMP_TESTDATE 
      FROM EMPLOYEE E
     WHERE E.EMPLOYEE_ID = :NEW.PILOT_ID;
    
    IF UPPER (TEMP_POSITION) <> 'PILOT' 
    THEN
       RAISE_APPLICATION_ERROR (-20001, 'Assigned employee is not a pilot');
    END IF;
    
    IF ( SYSDATE - TEMP_TESTDATE ) > 182 
    THEN
       RAISE_APPLICATION_ERROR (-20001, 'Assigned pilot has not been tested in the last 6 months');
    END IF;
    
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so I am creating an oracle database for my university coursework on an airline.
The university I work at uses Oracle for the database system. We currently have
As part of our University coursework we have to make a multi threading download
Background : For an university project I have to use PHP5 to create a
As part of a university project I have to do some signal processing and
I'm in University studying computer science. This is actually my first big assignment but
As part of a university project, we have to write a compiler for a
I am a university student. I have been working a lot with Android lately
I have been developing a website for a University coursework, and at the moment,
My university's website always crashes every day at this time of day and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.