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 > How to do a SELECT on a Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-11, 04:01
Nagashree Nagashree is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
Exclamation How to do a SELECT on a Stored Procedure

DELIMITER $$
create procedure `test`(a number,b number)
begin
DECLARE result;
set result=a+b;

END $$
DELIMITER



SELECT * from test(1,2);

Output should be 3
Here "test" is the name of the procedure. How to do this on MYSQL?? This works in SQL Server, but not on MYSQL.
I get 1064(42000) error in the line -SELECT * from test(1,2);

Last edited by Nagashree; 03-29-11 at 04:32.
Reply With Quote
  #2 (permalink)  
Old 03-29-11, 04:42
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
The closest you can get to what you are trying to do is creating a function rather than a procedure:

Code:
CREATE FUNCTION test(a DECIMAL,b DECIMAL)
RETURNS DECIMAL
NO SQL
BEGIN
	RETURN a+b;
END;
$$
Call the function you would issue:

Code:
SELECT test(1,4);
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 05-27-11, 08:38
Harisankar.A Harisankar.A is offline
Registered User
 
Join Date: May 2011
Posts: 11
How to do a SELECT on a Stored Procedure

In MySQL Syntax to call procedure is,

CALL procedure_name();


In your case CALL test(1,2);
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