Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Can I implement stored procedure in SQL which will return a result set?
Thu, Sep 13 2007 9:05 AMPermanent Link

Zdzislaw Kowalski
Is it possible to create stored procedure in manner similar to this:
"
CREATE PROCEDURE GetInfo()
BEGIN
  SELECT TT.Name,
              NT.Notes
  FROM    TestTable AS TT
              JOIN
              NextTable AS NT
  ON        TT.ID = NT.ID;
END;
".
Thu, Sep 13 2007 3:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Zdzislaw,

<< Is it possible to create stored procedure in manner similar to this: >>

Yes, use this:

CREATE PROCEDURE GetInfo()
BEGIN
  DECLARE TestCursor CURSOR WITH RETURN FOR TestStmt;

  PREPARE TestStmt FROM 'SELECT TT.Name, NT.Notes
                                               FROM TestTable AS TT
                                               JOIN NextTable AS NT ON
TT.ID = NT.ID';
  OPEN TestCursor;
END;

--
Tim Young
Elevate Software
www.elevatesoft.com

Image