SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Testing a Stored Procedure

    If I have a Stored Procedure like this...

    Code:
    DELIMITER $$
    CREATE PROCEDURE select_customer(type VARCHAR(10))
    BEGIN
    	IF cust_type = 'premium' THEN
    		SELECT *
    		FROM customers
    		WHERE type = 'premium';
    	ELSE
    		SELECT *
    		FROM customers;
    	END IF;
    END$$
    DELIMITER;

    Shouldn't I be able to test the Stored Procedure with a call like this??

    Code:
    CALL select_customer('premium');
    I tried that with an example in my book and it gave me an error.



    TomTees

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    and the error was ... ?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist TomTees's Avatar
    Join Date
    Apr 2010
    Location
    Iowa
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    and the error was ... ?

    Error

    SQL query: Documentation

    CALL select_customer(
    'premium'
    )

    MySQL said: Documentation
    #1312 - PROCEDURE customer_db.select_customer can't return a result set in the given context

    TomTees


Bookmarks

Posting Permissions

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