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 > Concat inside Concat to call another procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-10, 06:39
vsaravanamuthu vsaravanamuthu is offline
Registered User
 
Join Date: Apr 2010
Posts: 2
Concat inside Concat to call another procedure

Hi ,

I got struct over here , i am getting NULL when i am running this procedure ...I call one procedure , where it has a call to another procedure ,
below is my proc named test_call ,where it call test_out, an another procedure

1 ...............

DELIMITER $$

DROP PROCEDURE IF EXISTS `test_call` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `test_call`()
BEGIN

/*
I am getting NULL when i run in and out as param , where as i am getting the result
when i am running this as in param ..
*/

# 1. Has in and out param
set @call2 = concat('call ' ,'test_out(',concat('21','0'),',',@b,')');
select @call2,@b;

# 2. Has in param only
#set @call2 = concat('call ' ,'test1(',concat('21','0'),')');
#select @call2;


PREPARE stmt2 FROM @call2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;


END $$

DELIMITER ;

----------------------------------------------------------------------
Proc 2
----------------------------------------------------------------------
DELIMITER $$

DROP PROCEDURE IF EXISTS `test_out` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `test_out`(in numbersWith2Digit varchar(5),out sa text)
BEGIN

set @c = concat('123','456',concat('789'),numbersWith2Digit );
set sa = @c;
select sa;

END $$

DELIMITER ;
-------------------------------------------------------------------
Reply With Quote
  #2 (permalink)  
Old 04-19-10, 10:46
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Firstly, test_call is expecting @b before it is called. If you do not set this the result of the concat will be NULL.

Secondly, the IN OUT parameter must be a variable name and not a value. So in the first procedure test_call() you must define @b inside a string variable

Code:
DROP PROCEDURE IF EXISTS `test_call` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `test_call`()
BEGIN

/*
I am getting NULL when i run in and out as param , where as i am getting the result
when i am running this as in param ..
*/

# 1. Has in and out param
set @call2 = concat('call ' ,'test_out(',concat('21','0'),',','@b',')');
select @call2,@b;

PREPARE stmt2 FROM @call2;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt2;


END $$

DELIMITER ;
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 04-20-10, 03:06
vsaravanamuthu vsaravanamuthu is offline
Registered User
 
Join Date: Apr 2010
Posts: 2
Smile

Hi Ronan,

Thankyou very much for the reply... Now i understand where i did the mistake .Now code is working properly...
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