Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    3

    Exclamation Unanswered: 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 05:32.

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    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);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •