Results 1 to 2 of 2

Thread: Syntax error creating procedure MySQL5

  1. #1

    Thread Starter
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Syntax error creating procedure MySQL5

    I am using mysql 5 and mysql query browser 1.1.15

    Code:
    DROP TABLE IF EXISTS `mindsolutions`.`encomendas`;
    CREATE TABLE  `mindsolutions`.`encomendas` (
      `numenc` int(10) unsigned NOT NULL auto_increment,
      `cliente` varchar(45) NOT NULL,
      `dataabertura` datetime NOT NULL,
      `designacao` varchar(255) NOT NULL,
      `obs` varchar(255) default NULL,
      `preco` decimal(10,0) NOT NULL,
      `estado` varchar(45) default '',
      `documentacao` varchar(255) default NULL,
      `responsavel` varchar(45) default '',
      PRIMARY KEY  (`numenc`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    Code:
    delimiter$$
    CREATE PROCEDURE mindsolutions.grava_encomenda (in numenc int(10),  in cliente varchar(45) ,  in dataabertura datetime ,  in designacao varchar(255),  in obs varchar(255),  in preco decimal(10,0),  in estado varchar(45) ,  in documentacao varchar(255),  in responsavel varchar(45))
    BEGIN
    	if not exists (select * from mindsolutions.encomendas where numenc = numenc);
    		insert into mindsolutions.encomendas values(numenc,cliente,dataabertura,designacao,obs,preco,estado,documentacao,responsavel);
    END$$
    delimiter;
    error:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rigth syntax near ';insert into mindsolutions.encomendas values(numenc,cliente,dataabertura,des' at line 3

    Any suggestion?

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Syntax error creating procedure MySQL5

    I would guess that you should not have a ; at the end of the line before, as that is typically used as an end of statement marker (and is causes confusion about the If).

Posting Permissions

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



Click Here to Expand Forum to Full Width