Forum Moderators: open

Message Too Old, No Replies

MySql - STored Procedure

         

Jagjit

9:39 am on Oct 5, 2011 (gmt 0)

10+ Year Member



Error : #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 '' at line 20

Create PROCEDURE Sp_InsertCountry
(
pcode char(3),
pname varchar(50),
paddress1 varchar(50),
paddress2 varchar(50),
pphone1 varchar(25),
pphone2 varchar(25),
pfaxno varchar(25),
plstno varchar(50),
pcstno varchar(25),
ptanno varchar(25),
pcity varchar(25),
pstate varchar(25),
pzip int,
pstatus varchar(1)
)
BEGIN
insert into company (code,name,address1,address2,phone1,phone2,faxno,tanno,lstno,cstno,city,state,zip,status)
values (pcode,pname,paddress1,paddress2,pphone1,pphone2,pfaxno,ptanno,plstno,pcstno,pcity,pstate,pzip,pstatus);
END
GO

arms

12:55 pm on Oct 5, 2011 (gmt 0)

10+ Year Member



According to Mysql docs you may have to declare variable direction:

Create PROCEDURE Sp_InsertCountry
(
IN pcode char(3),
IN pname varchar(50),
IN paddress1 varchar(50),
IN paddress2 varchar(50),
IN pphone1 varchar(25),
IN pphone2 varchar(25),
IN pfaxno varchar(25),
IN plstno varchar(50),
IN pcstno varchar(25),
IN ptanno varchar(25),
IN pcity varchar(25),
IN pstate varchar(25),
IN pzip int,
IN pstatus varchar(1)
)
BEGIN
insert into company (code,name,address1,address2,phone1,phone2,faxno,tanno,lstno,cstno,city,state,zip,status)
values (pcode,pname,paddress1,paddress2,pphone1,pphone2,pfaxno,ptanno,plstno,pcstno,pcity,pstate,pzip,pstatus);
END
GO

other than that do the variables def match the columns def in the table?, that's the only other thing I can think of

topr8

2:13 pm on Oct 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I use stored procedures in mySQL all the time and haven't used IN before.

where are you getting the error message? from a php page?

it seems to me there is nothing wrong with the stored procedure itself, if you are using mySQl workbench you don't need to include GO