Subject | RE: [firebird-support] SQL select with procedure |
---|---|
Author | Paul Lopez |
Post date | 2011-07-05T04:32:55Z |
> -----Original Message-----Hi
> Subject: [firebird-support] SQL select with procedure
>
>
> Hi
>
> On some occasions we have wanted to do a multiple join query where we
> have also wanted to join the results of a parameterised stored procedure.
> However I have never succeeded. I have tried something like
>
> SELECT *
> FROM Tablea a
> Join Tableb b ON b.id = a.id
> etc
> JOIN (SELECT * FROM StoredProc(a.id, b.somefield) ) sp ON 1 = 1
>
> This does not work. Could someone enlighten me on the appropriate syntax
> to achieve this :)
>
> We have usually resorted to
>
> Select a.id, (select Val1 from StoredProc(a.id, b.somefield)) As Val1, (select
> Val2 from StoredProc(a.id, b.somefield)) As Val2 FROM Tablea a Join Tableb b
> ON b.id = a.id etc
>
>
> However the above seems very inefficient where multiple fields are
> required from the stored procedure.
>
>
> thanks
> Rob
Try this:
SELECT *
FROM Tablea a
Join Tableb b ON b.id = a.id
JOIN StoredProc(a.id, b.somefield) ) sp ON 1 = 1