Subject Re: [firebird-support] Is there a way to pass a result set as a parameter?
Author Martijn Tonies
Hi,

> Let's say I have a very simple stored procedure:
> CREATE PROCEDURE UpdateByParentID (
> AValue integer,
> AParentID integer)
> AS BEGIN
> UPDATE SomeTable SET SomeColumn = :AValue WHERE
> ParentID = :AParentID;
> END;
>
> ...and I want to call it with a number of ParentIDs derived from a
> result set. Something like:
>
> EXECUTE PROCEDURE
> UpdateByParentID (1, 'SELECT ParentID FROM SomeOtherTable WHERE
> SomeOtherID BETWEEN 1 AND 10')
>
> or
> EXECUTE PROCEDURE
> UpdateByParentID (1, 'SELECT ParentID FROM SomeOtherTable WHERE
> SomeOtherCost BETWEEN 50 AND 200')
>
> or...
>
> Well, you get the idea. The query that generates the list of
> ParentIDs, can be as simple or complicated as I would like. Is
> there a way to pass a result set as a parameter? There may be
> hundreds or thousands of ParentIDs that need to be passed.
>
> Any help would be appreciated.

No, you cannot use it as that. Pass each "ParentID" individually, or
pass a WHERE clause that can be used in FOR EXECUTE STATEMENT ...

Have a look at the Firebird 1.5 release notes for that.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com