Subject Re: [firebird-support] "for select' with 'ORDER" clause in stored procedure
Author Ismael L. Donis GarcĂ­a
Have you tried the last photo? (Firebird-2.1.4.18347-0_Win32.zip)

I understand that that problem already is revised in the same.

Anyway try putting order by 1

Regards
=========
|| ISMAEL ||
=========
----- Original Message -----
From: Christian Waldmann
To: firebird-support@yahoogroups.com
Sent: Tuesday, September 21, 2010 10:15 AM
Subject: [firebird-support] "for select' with 'ORDER" clause in stored procedure



Hello

Environment: Windows XP SP3, Firebird 2.1.3 SuperServer, IBExpert,
Development Server, only 1 connection (SYSDBA in IBExpert)

I use the following selct in a SQL-Editor and the result is ordered by
o.LOGTIMESTAMP

select cast( o.LOGTIMESTAMP as time) as logtime, cast(
t.logtimestamp as time) - cast( o.logtimestamp as time ),
o.food - t.food as foodDelta,
o.kind
from procGetAnimalVisitKindSP1( :animal, :visitDate, 'O',
'V' ) o /* V)isit, O)pen */
inner join procGetAnimalVisitKindSP1( :animal, :visitDate,
'C', 'L') t /* L)eaving, C)lose */
on (o.visitId = t.visitId)
where o.UNIQUEID < t.UNIQUEID
order by o.LOGTIMESTAMP /*
<======================== */

I use the same select in a for loop in a stored procedure. The procedure
compiles and runs, but the order clause has no effect!
(The result set is returned in the order of o.visitid)

stored Procedure ....

for select cast( o.logtimestamp as time ) as logtime,
cast( t.logtimestamp as time) - cast( o.logtimestamp as time
),
o.food - t.food as foodDelta,
o.kind
from procGetAnimalVisitKindSP1( :animal, :visitDate, 'O', 'V' )
o /* V)isit, O)pen */
inner join procGetAnimalVisitKindSP1( :animal, :visitDate,
'C', 'L') t /* L)eaving, C)lose */
on (o.visitId = t.visitId)
where o.UNIQUEID < t.UNIQUEID
order by o.LOGTIMESTAMP /*
<======================== */
into :visitTime, :visitDuration, :visitDelta, var_arrivalKind
do begin
/* some code */
suspend;
end

Is the order clause useless by design in a "for ... select ORDER into
.. begin SUSPEND; end" construct?
If so, I would expect an error or at least a warning!
If not, what am I doing wrong?

Christian Waldmann




[Non-text portions of this message have been removed]