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 9160279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:42:03+00:00 2026-06-17T13:42:03+00:00

When i execute this trigger it throws error as #1064 – You have an

  • 0

When i execute this trigger it throws error as

#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘END’ at line 27

delimiter //

CREATE TRIGGER `after_tblgps_insert` AFTER INSERT ON `tbl_gps`
FOR EACH ROW BEGIN
DECLARE cab_meter_new VARCHAR(10);
DECLARE cab_cost_new VARCHAR(10);
DECLARE cab_meter_old VARCHAR(10);
DECLARE cab_cost_old VARCHAR(10);
DECLARE pr_pnr_no  VARCHAR(15);
DECLARE pr_dest_id  VARCHAR(15);

select NEW.gps_rs232,NEW.gps_cab_bus,gps_rs232,gps_cab_bus into @cab_meter_new,@cab_cost_new,@cab_meter_old,@cab_cost_old from tbl_gps where gps_imei = NEW.gps_imei order by gps_id asc limit 0,1;

IF @cab_meter_new = 1 and @cab_meter_old = 0 THEN
BEGIN
select `booking_pnr_no` into @pr_pnr_no from tbl_booking where booking_alloted_vehicle = (select taxi_id from tbl_taxi where taxi_imei = NEW.gps_imei ) AND booking_status = 13;
select trip_dst_area_id into @pr_dest_no from tbl_trip where pnr_id = @pr_pnr_no order by trip_id desc limit 0,1;
update tbl_taxi set taxi_cur_status = 12,taxi_cur_area = @pr_dest_no where taxi_id = NEW.gps_cab_bus;
update tbl_booking set booking_status = 9 where booking_pnr_no = @pr_pnr_no;
END;
ELSE IF @cab_meter_new = 0 and @cab_meter_old = 1 THEN
BEGIN
select `booking_pnr_no` into @pr_pnr_no from tbl_booking where booking_alloted_vehicle = (select taxi_id from tbl_taxi where taxi_imei = NEW.gps_imei ) AND booking_status = 9;
select trip_dst_area_id into @pr_dest_no from tbl_trip where pnr_id = @pr_pnr_no order by trip_id desc limit 0,1;
update tbl_taxi set taxi_cur_status = 10,taxi_cur_area = @pr_dest_no where taxi_id = NEW.gps_cab_bus;
update tbl_booking set booking_status = 8 where booking_pnr_no = @pr_pnr_no;
END;
END IF
END //
delimiter ;
  • 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-06-17T13:42:04+00:00Added an answer on June 17, 2026 at 1:42 pm

    try this code

    delimiter //
    
    CREATE TRIGGER `after_tblgps_insert` AFTER INSERT ON `tbl_gps`
    FOR EACH ROW BEGIN
    DECLARE cab_meter_new VARCHAR(10);
    DECLARE cab_cost_new VARCHAR(10);
    
        DECLARE cab_meter_old VARCHAR(10);
        DECLARE cab_cost_old VARCHAR(10);
        DECLARE pr_pnr_no  VARCHAR(15);
        DECLARE pr_dest_id  VARCHAR(15);
    
        select NEW.gps_rs232,NEW.gps_cab_bus,gps_rs232,gps_cab_bus into @cab_meter_new,@cab_cost_new,@cab_meter_old,@cab_cost_old from tbl_gps where gps_imei = NEW.gps_imei order by gps_id asc limit 0,1;
    
        IF @cab_meter_new = 1 and @cab_meter_old = 0 THEN
        BEGIN
        select `booking_pnr_no` into @pr_pnr_no from tbl_booking where booking_alloted_vehicle = (select taxi_id from tbl_taxi where taxi_imei = NEW.gps_imei ) AND booking_status = 13;
        select trip_dst_area_id into @pr_dest_no from tbl_trip where pnr_id = @pr_pnr_no order by trip_id desc limit 0,1;
        update tbl_taxi set taxi_cur_status = 12,taxi_cur_area = @pr_dest_no where taxi_id = NEW.gps_cab_bus;
        update tbl_booking set booking_status = 9 where booking_pnr_no = @pr_pnr_no;
        END;
        END IF;
        IF @cab_meter_new = 0 and @cab_meter_old = 1 THEN//break IF into separate IF 
        BEGIN
        select `booking_pnr_no` into @pr_pnr_no from tbl_booking where booking_alloted_vehicle = (select taxi_id from tbl_taxi where taxi_imei = NEW.gps_imei ) AND booking_status = 9;
        select trip_dst_area_id into @pr_dest_no from tbl_trip where pnr_id = @pr_pnr_no order by trip_id desc limit 0,1;
        update tbl_taxi set taxi_cur_status = 10,taxi_cur_area = @pr_dest_no where taxi_id = NEW.gps_cab_bus;
        update tbl_booking set booking_status = 8 where booking_pnr_no = @pr_pnr_no;
        END;
        END IF;
        END; //
        delimiter ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an insert trigger that contains dynamic sql stored as a resource for
I have this Trigger in Postgresql that I can't just get to work (does
I want to execute this script (view source) that uses Google Translate AJAX API
When I try to execute this statement in Oracle SQL Developer 2.1 a dialog
I have been told to create a trigger for inserts on our SQL Server
I have this trigger procedure CASE_A as UPDATE table1 SET field1 = (SELECT bus
I have issues creating this trigger second_loop in sqlite3: It is part of more
In a trigger I want to see what sql query triggered this trigger. I
I have a service that keeps running, and a Timer in there to execute
I have a trigger that executes a function on table insert or update. 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.