|Subject||Re: [IBO] Order of Execution|
> Don't know if this is a IB or IBO question, but...It is an IB/FB question, but it just so happens that I was reading
about some of this stuff recently...
> If I have a inline SELECT embedded within another SELECT, whichIt depends on where the inline select is embedded and what type
> SELECT is executed first?
of embedding it is. The documentation (Embedded SQL Guide) only
discusses subqueries inside the WHERE clause, and it says:
"Because a subquery is a search condition, it is usually evaluated
before its parent query, which then uses the result to determine
whether or not a row qualifies for retrieval. The only exception is
the correlated subquery, where the parent query provides values for
the subquery to evaluate. For more information about correlated
subqueries, see Correlated subqueries on page 163."
> If the inline SELECT is executed last, then I could use theBy this I presume you are talking about selects inline in the field
> results of the outer SELECT as inputs into a inline selectable SP.
list. And the answer is yes you can.
(SELECT X FROM PROC(A.ID)) AS TEST
is really equivalent to the non procedure form of the same thing:
(SELECT X FROM B WHERE B.ID=A.ID) AS TEST
It is not so much that the inline select is executed last, as the
fact that it is executed for every row of the outer select.