Safwan Bardolia
Safwan Bardolia

Reputation: 619

pl/sql: You have an error in your SQL syntax how to fix this error?

I am creating a new procedure and I got an error :

You have an error in your SQL syntax

How to fix this error ? Is there a problem of quotes ?

  delimiter //
  MariaDB [assign5]> create procedure doissuebook(p1 int ,p2    
  varchar(20),p3 varchar(20),p4 varchar(30))
-> X: Begin
-> set @p3val=str_to_date(p3,'%d/%m/%y');
-> set @p5val="I";
-> --Exception handling
-> set @errormsg='';
-> if p1 <=0 then
-> begin
->          set @errormsg='Wrong roll number specified';
->          select @errormsg;
->          leave X;
-> end;
-> end if;
-> if length(p4) <=0 then
-> begin
->          set @errormsg='Wrong book specified';
->          select @errormsg;
->          leave X;
-> end;
-> end if;
-> insert into borrower (roll_no,name,DateOfIssue,NameOfBook,status)  
values (p1,p2,@p3val,p4,@p5val);
-> END
-> //

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax to
use near '--Exception handling set @errormsg=''; if p1 <=0 then begin set @errormsg='Wro' at line 5

Upvotes: 0

Views: 66

Answers (1)

TrayMan
TrayMan

Reputation: 7445

The line --Exception handling is a comment. MariaDB requires a space after the two dashes , so change to -- Exception handling.

Upvotes: 1

Related Questions