Subject | Re: [firebird-support] Error report: SP return and as |
---|---|
Author | Helen Borrie |
Post date | 2004-08-06T23:08:54Z |
At 11:24 PM 6/08/2004 +0200, you wrote:
If you order by a derived column, you must use the degree number (that's
the left-to-right position of the derived column as listed in the SELECT
specification).
So, to make this query work, you must know what the position is. With
SELECT * FROM this will break things if a table structure gets changed, so
use a proper column list in these cases.
select
A.column1,
A.columnX,
(select B.BBBBData from GET_From_BBBB(A.ID1, A.ID2)) as Bdata
from AAAA A
order by 3
Note, if the stored procedure can return multiple rows, you will get a
different error...Multiple rows in singleton select
/heLen
>FB 1.5.1Yes. :-)
>
>When I exequte this SQL command, the result is OK:
>
>select A.*,
> (select BBBBData from GET_From_BBBB(A.ID1, A.ID2)) as Bdata
> from AAAA A
>
>I see Bdata column too in the result dataset;)
>
>-------------------------------------------
>
>When I add an order tag, I get an error message:
>
>select A.*,
> (select BBBBData from GET_From_BBBB(A.ID1, A.ID2)) as Bdata
> from AAAA A
> order by Bdata
>
> >>>
>
>Dynamic SQL Error
>SQL error code = -206
>Column unknown
>Bdata
>
>-------------------------------------------
>
>Is it an error or I do something wrong?
If you order by a derived column, you must use the degree number (that's
the left-to-right position of the derived column as listed in the SELECT
specification).
So, to make this query work, you must know what the position is. With
SELECT * FROM this will break things if a table structure gets changed, so
use a proper column list in these cases.
select
A.column1,
A.columnX,
(select B.BBBBData from GET_From_BBBB(A.ID1, A.ID2)) as Bdata
from AAAA A
order by 3
Note, if the stored procedure can return multiple rows, you will get a
different error...Multiple rows in singleton select
/heLen