If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Not able to assign variable without using SET

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-08, 09:23
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Not able to assign variable without using SET

PHP Code:
DROP FUNCTION IF EXISTS `foo`;
DELIMITER $$$
CREATE FUNCTION `foo`(n INTRETURNS VARCHAR(100NO SQL
BEGIN
       
DECLARE asciir INT;
       
SET r FLOOR(RAND() * 35);

       IF 
10 THEN
          SET ascii 
48;
       ELSE
          
SET ascii 65;
       
END IF;

       RETURN 
ascii;
END $$$
DELIMITER 
Based on the manual, setting a variable without using the SET command should work.
But I cant seem to do ascii = r + 48; - never works. I have to use SET.
Why do I need to use the SET keyword to make it work ?

PHP Code:
DROP FUNCTION IF EXISTS `foo`;
DELIMITER $$$
CREATE FUNCTION `foo`(n INTRETURNS VARCHAR(100NO SQL
BEGIN
       
DECLARE asciir INT;
       
FLOOR(RAND() * 35);

       IF 
10 THEN
          ascii 
48;
       ELSE
          
ascii 65;
       
END IF;

       RETURN 
ascii;
END $$$
DELIMITER 
MySQL 5.0.45-community-nt
__________________
MySQL 5.1

Last edited by anjanesh; 03-13-08 at 09:28.
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On