MySQL Forums
Forum List  »  Stored Procedures

How to define a constant that could be used across several procedures?
Posted by: staszek findeisen
Date: July 27, 2009 12:16PM

Hello, how to define a constant that I could use across several stored procedures?

I tried user-defined variables for this, like this:

SET @myVar = 3;

but it looks that they are bound dynamically. That is, if I use @myVar to define stored procedure:

CREATE FUNCTION verifyTicket(ticketId VARCHAR(128)) RETURNS TINYINT
READS SQL DATA
MODIFIES SQL DATA
BEGIN
..... something with @myVar (read-only) .......
END

then @myVar value is NOT bound to verifyTicket definition! That is, when I next execute verifyTicket without first defining @myVar, then @myVar inside verifyTicket is NULL.

The only workaround I can think of is to define another procedure just to set my "constants" (that is, user-defined variables as above), and call it from every client upon connection. But that would be crazy.

Any ideas? Or maybe I am wrong?
Thanks!

Options: ReplyQuote




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.