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

  • SEARCH
  • Home
  • 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 6801419
In Process

The Archive Base Latest Questions

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

I am trying to create a trigger in Oracle. I know sql but i

  • 0

I am trying to create a trigger in Oracle. I know sql but i have never created trigger before. I have this code:

create or replace trigger "PASSENGER_BOOKING_T1"
AFTER
insert on "PASSENGER_BOOKING"
for each row
begin
IF (:NEW.CLASS_TYPE == 'ECO')

SELECT F.AVL_SEATS_ECOCLASS,F.FLIGHT_ID INTO SEAT, FLIGHT_INFO 
FROM BOOKING B, JOURNEY_FLIGHT J, FLIGHT F 
WHERE B.JOURNEY_ID = J.JOURNEY_ID and F.FLIGHT_ID = J.FLIGHT_ID;

UPDATE FLIGHT 
SET AVL_SEATS_ECOCLASS = (SEAT-1)
WHERE FLIGHT_ID = FLIGHT_INFO;

END IF;
end;​

This trigger fires when there is an insert in Passenger_Booking table. And seating capacity is reduced by one (which is at different table).

Select query should be alright but there is something wrong in somewhere.
Could anyone suggest anything?

I changed the body part to this but still having issues:

UPDATE FLIGHT 
SET AVL_SEATS_ECOCLASS =
  (SELECT F.AVL_SEATS_ECOCLASS FROM BOOKING B, JOURNEY_FLIGHT J, FLIGHT F WHERE B.JOURNEY_ID = J.JOURNEY_ID and F.FLIGHT_ID = J.FLIGHT_ID;
);
  • 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:05:53+00:00Added an answer on May 26, 2026 at 7:05 pm
    1. An IF statement needs a THEN
    2. In PL/SQL, you use an = to test for equality, not ==
    3. You need to declare the variables that you are selecting into

    When I do those three things, I get something like this

    create or replace trigger PASSENGER_BOOKING_T1
      AFTER insert on PASSENGER_BOOKING
      for each row
    declare
      l_seat       flight.seat%type;
      l_flight_id  flight.flight_id%type;
    begin
      IF (:NEW.CLASS_TYPE = 'ECO')
      THEN
        SELECT F.AVL_SEATS_ECOCLASS,F.FLIGHT_ID 
          INTO l_seat, l_flight_id
          FROM BOOKING B, 
               JOURNEY_FLIGHT J, 
               FLIGHT F 
         WHERE B.JOURNEY_ID = J.JOURNEY_ID 
           and F.FLIGHT_ID = J.FLIGHT_ID;
    
        UPDATE FLIGHT 
           SET AVL_SEATS_ECOCLASS = (l_seat-1)
         WHERE FLIGHT_ID = l_flight_id;   
      END IF;
    end;​
    

    Beyond those syntax errors, I would be shocked if the SELECT INTO statement was correct. A SELECT INTO must return exactly 1 row. Your query should almost certainly return multiple rows since there are no predicates that would restrict the query to a particular flight or a particular booking. Presumably, you want to join to one or more columns in the PASSENGER_BOOKING table.

    Additionally, if this is something other than a homework assignment, make sure you understand that this sort of trigger does not work correctly in a multi-user environment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Oracle 10gR2. I am trying to create autoincrement trigger. Here is the
I´m trying to create a trigger on MySQL but I´m having a syntax problem,
With MySQL 5.1.43. I am trying to create a trigger like this: USE `databaseA`;
Trying to create an Oracle trigger that runs after a table is updated in
When trying to create the trigger below, I get this message #1064 - You
I am trying to create a trigger in SQL Server 2008 which inserts a
I am trying to create a BEFORE INSERT trigger that will check the incoming
i'm trying to make a TRIGGER in ORACLE using ORACLE SQL DEVELOPER, I would
I'm trying to create a DDL trigger for a specific table and this is
This is my problem i'm trying to create a event to trigger a draggable.

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.