MySQL Forums
Forum List  »  Stored Procedures

Re: Dynamic SQL. Is it possible?
Posted by: Roland Bouman
Date: November 04, 2005 05:21PM

1. I suspec you have version 5.0.15. To be sure, do:

SELECT version();

2. Yes, I made it up. You can't declare these user variables, or rather, referencing one implicitly declares it. The type is a runtime type: it is the type of whatever value you assigned to it.


3. Good Question! Yes and No. Depending upon the context = means either assignment or equals. This can be confusing sometimes:

create procedure p()
declare v1 int;
declare v2 int default 1;
set v1 = v2 = 0; -- leftmost means assign, rightmost means equals
select v1, v2;

To prove that is can be really confusing, start a new, clean session, and do this:

select @v:=1, @v=0;

What would be the value of @v now? First, try and predict, then do:

select @v;


I'm used to Oracle PLSQL, wich uses := for assignment, and = for equals (there's one exception, in the SET clause of an UPDATE statement = means assign. It would be a breach to standard sql to allow the := there. Interestingly, mysql DOES accept a := in the SET clause of an UPDATE statment)
So, I try to use := as much as I can to denote assignment (but I make the same exception as oracle does, I never use it in the SET of an UPDATE).

4) I wouldnt know. Maybe there's a feature request out already?

Options: ReplyQuote

Written By
November 04, 2005 01:40AM
November 04, 2005 03:51AM
November 04, 2005 08:51AM
November 23, 2005 10:50AM
November 23, 2005 02:18PM
November 04, 2005 08:54AM
November 04, 2005 03:40PM
Re: Dynamic SQL. Is it possible?
November 04, 2005 05:21PM

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.