At 3:00 PM +1100 1/22/07, Daniel Kasak wrote:
Hi all.

I'd like to be able to define a stored procedure that returns a recordset ( I've done this bit ), and then select from this in another query, eg:

CREATE [EMAIL PROTECTED] PROCEDURE `sp_MyClients`( IN ACCMAN INT )
BEGIN
select * from mirror_Clients where AccMan = ACCMAN;
END

... and then:

select
C.FileNo, C.SubNo, L.AccountNo
from
( sp_MyClients ( 192 ) ) C inner join TLocations T on C.ClientID = T.ClientID;

I've also tried adding 'call' immediately before the 'sp_MyClients' bit. Either way, I get:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( 192 ) ) C inner join TLocations T on C.ClientID = T.ClientID' at line 1

I assume it's not possible to do this then?

I realise I can skip the stored procedure in this case and just add the where clause from the SP to the query, but in some other cases, the SP bit will be quite complex.

Stored procedures that generate result sets return them directly to the
client, not to another query.  Perhaps you could accomplish what you want
by selecting the result set into another table and reading from that table
in subsequent queries.

--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to