Subject | Re: join stored procedure and select |
---|---|
Author | intranetsbi |
Post date | 2005-07-26T10:09:25Z |
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
I was mainly working with Oracle where this kind of use is possible.
I was thinking about your solution beforehand. What bothers me is
that I have to declare all the return columns in a SP (There's no
rowtype variable?), then again I have to declare them in .NET app and
then tippically table changes...
But you are absolutely correct! Thanks again!
wrote:
> At 12:20 PM 25/07/2005 +0000, you wrote:has a
> >Hello!
> >I created stored procedure that returns 0/1 depending if a user
> >role or not. HasRole(UserID,Rolename):returns 0/1role.
> >
> >Now I'd like to run a select from all users which have a certain
> >Why "select * from users, HasRole(users.id,'Admin')" is notworking?
>provided the SP
> Because it can't. You can join a table to a selectable SP,
> has an output field that can be matched to a key in the table. Itis
> horribly inefficient, too. I regard it as one of those things youreturn your
> shouldn't try to do just because you can....
>
> Write an SP to process the users, calling your SP for each and
> user list directly, along the lines ofThank you! I got your point!
>
> create procedure GetUserListForRole (Rolename varchar(31))
> returns (id BigInt, username varchar(31), whatever sometype, ....)
> as
> declare Result smallint;
> begin
> for select id, username, whatever, .... from users
> into :id, :username, :whatever, ...
> do
> begin
> execute procedure HasRole(:id, :Rolename)
> returning_values(:Result);
> if (Result = 1) then
> suspend;
> end
> end
>
> Then, your application does
>
> select * from GetUserListForRole('Admin')
I was mainly working with Oracle where this kind of use is possible.
I was thinking about your solution beforehand. What bothers me is
that I have to declare all the return columns in a SP (There's no
rowtype variable?), then again I have to declare them in .NET app and
then tippically table changes...
But you are absolutely correct! Thanks again!