Welcome to WebmasterWorld Guest from 23.22.220.37

Forum Moderators: open

Message Too Old, No Replies

MySql - STored Procedure

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

New User

joined:Sept 29, 2011
posts: 3
votes: 0


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
12:55 pm on Oct 5, 2011 (gmt 0)

New User

joined:Feb 22, 2011
posts:22
votes: 0


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
2:13 pm on Oct 5, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2002
posts:3171
votes: 8


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
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members