Subject Re: Using stored procedure results in the WHERE clause
Author sboydlns
--- In firebird-support@yahoogroups.com, André Knappstein <Knappstein@...> wrote:
>
> > If I use a COMPUTED column, any time I use SELECT * FROM
> > OPS_STOP_REC that column is going to be evaluated. This would end up
> > doing a lot of I/O in those cases where I don't care about the value
> > of the computed column.
>
> I'd bet that if you can afford to be careless about specifying the
> column list exactly, and thereby causing already a lot of overhead in
> the datastream and buffers, the tiny little bit of computing the
> column should not matter.

Not wanting to start the whole SELECT * debate again, but if you need all of even the majority of the fields in the row then using SELECT * is not "careless" IMHO. It also simplifies program maintenance when new fields are added to the table. I would also have to think that a bit of overhead marshalling and unmarshalling some extra fields would pale to insignificance compared to having to do a bunch of I/O to match rows from other tables. Again IMHO.

>
>
> As an alternative, you can put the functionality you want into one
> stored procedure (using, for example, a For... Select... into...).
> You can make extra use of some "execute statement" here and there to
> generalize the procedure and call the same procedure for different
> purposes.
>

That's what I'm trying to do but having trouble with the syntax.

I have finally come to the conclusion that there are 2 ways to go about it.

SELECT *
FROM OPS_STOP_REC
JOIN IS_MANIFESTED(OPS_STOP_ID) ON RESULT = 0 /* not manifested */
...

or

SELECT *
FROM OPS_STOP_REC
WHERE EXISTS (SELECT IS_MANIFESTED(OPS_STOP_REC) WHERE RESULT = 0)
...

Both would seem to be functionally equivalent.