Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    137

    Unanswered: syntax error for simple IF - THEN

    Hi,

    I am trying to creat a simple IF - THEN in MySQL but getting a synax error message.

    can anyone help please...

    here is my statement:

    IF EXISTS (SELECT payroll_id FROM payroll WHERE location_id = param_location AND payroll_month = param_month AND payroll_year = param_year) THEN
    SET param_payroll_id = 0;
    END IF;


    Thanks,
    Jassim

  2. #2
    Join Date
    Sep 2007
    Location
    Bangalore India
    Posts
    28
    Hi jrahma,

    Check if your IN & OUT parameters added properly, also I have shared the simple sp.
    DELIMITER $$
    DROP PROCEDURE IF EXISTS `test`.`sp_check` $$
    CREATE PROCEDURE sp_check(IN id INT(4),OUT param_payroll_id INT(4))
    BEGIN
    IF exists (select id from mytable where id=id) THEN
    set param_payroll_id = 0;
    END IF;
    select param_payroll_id;
    END$$
    DELIMITER

Posting Permissions

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