MySQL Forums
Forum List  »  Microsoft SQL Server

Re: Using @ (at) sign in stored procedures
Posted by: Roland Bouman
Date: November 19, 2005 07:49PM

The @ variables are so-called user variables, see:

http://dev.mysql.com/doc/refman/5.0/en/Variables.html
http://dev.mysql.com/doc/refman/5.0/en/example-user-variables.html

these are defined in the session scope. They cant be declared either (or better, a reference implicitly declares it if it didnt exist already)

So, your snippet nearly works (declaration is bogging you now):

Create Procedure testproc()
as
select * from testtable where field1 = @test1

should work fine, but you must be really careful.
If there's another process that unexpectedly sets the value of @test1, you could get into trouble.

Therefore, I recommend you rewrite it with normal parameters:


Create Procedure testproc(
p_test1 varchar(32)
)
as
select * from testtable where field1 = p_test1


these are defined in the scope of the procedure so you cannot get weird sidefx

Options: ReplyQuote


Subject
Written By
Posted
Re: Using @ (at) sign in stored procedures
November 19, 2005 07:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.