Bluehost.com Web Hosting $6.95

newbie: What is wrong in this SP?

This is a discussion on newbie: What is wrong in this SP? within the MySQL Database forums, part of the Database Forums category; Hey I'm new to MySql5 and I'm trying to write my first stored procedure. Below is a stored ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-21-2007
Jeff
 
Posts: n/a
Default newbie: What is wrong in this SP?

Hey

I'm new to MySql5 and I'm trying to write my first stored procedure. Below
is a stored procedure I'm trying to add to the database, but it gives errors
(the 2 errors are listed below too)... I'm stucked here.

CREATE PROCEDURE SaveProperty()
BEGIN
DECLARE @var1 INT;
END;

ERROR 1064 (42000): 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
'@var1
INT' at line 3
mysql> END;
ERROR 1064 (42000): 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
'END'
at line 1

Any suggestions to what I'm doing wrong are welcome!

Jeff


Reply With Quote
  #2 (permalink)  
Old 01-22-2007
Axel Schwenke
 
Posts: n/a
Default Re: newbie: What is wrong in this SP?

"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote:
>
> CREATE PROCEDURE SaveProperty()
> BEGIN
> DECLARE @var1 INT;
> END;
>
> ERROR 1064 (42000): 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 '@var1 INT' at line 3


> Any suggestions to what I'm doing wrong are welcome!


You're trying to declare a user variable. User variables have names
starting with @ and must not be declared. The scope of a user variable
is the connection, the scope of a local variable is the surrounding
BEGIN ... END block. Local variable names must not start with @.
Try this:

CREATE PROCEDURE SaveProperty()
BEGIN
DECLARE var1 INT;
END;


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #3 (permalink)  
Old 01-22-2007
Jeff
 
Posts: n/a
Default Re: newbie: What is wrong in this SP?

thanks


"Axel Schwenke" <axel.schwenke@gmx.de> wrote in message
news:99u0pe.d77.ln@xl.homelinux.org...
> "Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote:
>>
>> CREATE PROCEDURE SaveProperty()
>> BEGIN
>> DECLARE @var1 INT;
>> END;
>>
>> ERROR 1064 (42000): 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 '@var1 INT' at line 3

>
>> Any suggestions to what I'm doing wrong are welcome!

>
> You're trying to declare a user variable. User variables have names
> starting with @ and must not be declared. The scope of a user variable
> is the connection, the scope of a local variable is the surrounding
> BEGIN ... END block. Local variable names must not start with @.
> Try this:
>
> CREATE PROCEDURE SaveProperty()
> BEGIN
> DECLARE var1 INT;
> END;
>
>
> XL
> --
> Axel Schwenke, Support Engineer, MySQL AB
>
> Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
> MySQL User Forums: http://forums.mysql.com/



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:07 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0