TADOStoredProc problem




I have a TADOStoredProc where the stored procedure first of all
calls another stored proc and finally ends with a SELECT before
the Return statement :
...
EXEC @MyPost = [dbo].[sp_FindMyPost] @UserNum, @OnDate
...
SELECT UD.* FROM haUserData UD WHERE @MyPost = ...
Return 0

The inner stored proc 'sp_FindMyPost' contains the code :
...
SET @MyPost = (SELECT PP.haPost FROM haPersonPosts PP
WHERE ...)

IF @MyPost = NULL -- post NOT found
GOTO ExitWithError

RETURN @MyPost -- post found

ExitWithError:
SELECT NULL AS 'sp_FindMyPost'
RETURN -1

The problem is that the TADOStoredProc Fields Editor picks up the
column 'sp_FindMyPost' from the inner stored proc and NOT the
columns I want from 'UD.*' in the outer stored proc.

If I comment out the 'SELECT NULL AS ...' from the inner stored
proc then the TADOStoredProc won't open, saying 'CommandText does
not return a result set'.

It seems that the inner proc needs a SELECT statement, but that
this statement masks the outer proc's SELECT statement.

How do I make the TADOStoredProc pick up the 'UD.*' columns ?
The outer stored proc works correctly in MSSQL Query Analyzer.

Any suggestions gratefully accepted.

.



Relevant Pages