Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

unable to store the value of column in variable, SQL TRIGGERS

The booked_tickets table that I have created to store the info of the tickets

CREATE TABLE BOOKED_TICKETS( 
PNR_NO  NUMBER PRIMARY KEY, 
USER_ID  NUMBER,
TRAIN_NO  NUMBER,
SOURCE   VARCHAR2(50),  
DESTINATION  VARCHAR2(50),  
DATE_OF_ARRIV  DATE,
DATE_OF_BOOKING  DATE,
STATUS   VARCHAR2(50),
NO_OF_SEATS NUMBER,
BOOKED_CLASS  VARCHAR2(50),
SEAT_NO   NUMBER);

The Available_seats table to store the info of the seats available for each of the available class.

AVAILABLE_SEATS:
CREATE TABLE AVAILABLE_SEATS(
TRAIN_NO  NUMBER PRIMARY KEY,
SLEEPER_SEATS   NUMBER,
ONE_TIER_SEATS  NUMBER,
TWO_TIER_SEATS  NUMBER,
THREE_TIER_SEATS NUMBER,
GENERAL_SEATS  NUMBER);

This is the Query where am facing issue to store the value of avail seats into variable.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

create or replace trigger status_tgr
before insert on booked_tickets
for each row
follows tkt_capitalize_tgr
declare
availSeats int;
begin
select availSeats = sleeper_seats from AVAILABLE_SEATS where train_no = :new.train_no;
update AVAILABLE_SEATS set sleeper_seats = availSeats - (:new.no_of_seats) where train_no = (:new.train_no);
end;
/

Error

Error at line 4: PL/SQL: SQL Statement ignored

2. before insert on booked_tickets
3. for each row
4. follows tkt_capitalize_tgr
5. declare
6. availSeats int;

>Solution :

Check you tkt_capitalize_tgr trigger there might be some issue in that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading