Subject | Re: [IBO] Change ORDER changer to desc in OnPrepareSQL |
---|---|
Author | G. Nau |
Post date | 2005-02-10T15:15:01Z |
Am 10 Feb 2005 um 12:01 hat Helen Borrie geschrieben:
I've implemented an OnPrePapareSQL statement as you described
to invert the choose sorting, but it's not working.
a.) Is sqlorder WriteOnly? Every reference to sqlorder.commatext is
given empty strings, sqlorder.Count is always 0 no matter how many
ADDs I do)
b.) Sqlorder.add is only accepting single columnnames; I made
some tests with direct columnnames
b.1) SQLOrder.Add('KURZNAME,REF'); -> error: Table unknown
REF
b.1) SQLOrder.Add('KURZNAME DESC'); -> Token unknown
So I assume the parser isn't really accepting my entries, is it?
Here's the complete source of the OnPrepareSQL stuff ...
procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
VAR Feldname:String;
Sort : String;
Begin
with ib_query1 do
Begin
Feldname:=OrderingItems.IndexNames[OrderingItemNo-1];
If Forward then Sort:=''
Else Sort:=' DESC';
SQLOrder.Clear;
SQLOrder.Add(Feldname+Sort,',REF'+Sort);
allocconsole;
Writeln(sqlorder.Commatext);
Writeln(Sqlorder.count);
Writeln('something shown?');
sqlwhereitems.add('(');
sqlwhereitems.add('(');
//vorwärts
If Forward then sqlwhereitems.add(Feldname+'>:P1')
//rückwärts
Else sqlwhereitems.add(Feldname+'<:P1');
sqlwhereitems.add(')');
sqlwhereitems.add('OR');
sqlwhereitems.add('(');
//vorwärts
if Forward then sqlwhereitems.add(Feldname+'=:P1 and ref>:P2')
//rückwärts
Else sqlwhereitems.add(Feldname+'=:P1 and ref<:P2');
sqlwhereitems.add(')');
sqlwhereitems.add(')');
Writeln('SQLwhereitems:');
Writeln(SQLwhereitems.commatext);
End;
End;
Regards
Gunther
> The SQLOrder property is available in OnPrepareSQL (and not anywhere else):Helen,
>
> with MyDataset do
> begin
> SQLOrder.Clear;
> SQLOrder.Add('name desc, ref');
> SQLWhereItems...............
> end;
>
> OrderingItems is really a more flexible way to condition the set ordering,
> especially if you make the orderings available to the user for selection,
> because it gives you the opportunity to pre-define orderings based on good
> indexes.
>
I've implemented an OnPrePapareSQL statement as you described
to invert the choose sorting, but it's not working.
a.) Is sqlorder WriteOnly? Every reference to sqlorder.commatext is
given empty strings, sqlorder.Count is always 0 no matter how many
ADDs I do)
b.) Sqlorder.add is only accepting single columnnames; I made
some tests with direct columnnames
b.1) SQLOrder.Add('KURZNAME,REF'); -> error: Table unknown
REF
b.1) SQLOrder.Add('KURZNAME DESC'); -> Token unknown
So I assume the parser isn't really accepting my entries, is it?
Here's the complete source of the OnPrepareSQL stuff ...
procedure TForm1.IB_Query1PrepareSQL(Sender: TIB_Statement);
VAR Feldname:String;
Sort : String;
Begin
with ib_query1 do
Begin
Feldname:=OrderingItems.IndexNames[OrderingItemNo-1];
If Forward then Sort:=''
Else Sort:=' DESC';
SQLOrder.Clear;
SQLOrder.Add(Feldname+Sort,',REF'+Sort);
allocconsole;
Writeln(sqlorder.Commatext);
Writeln(Sqlorder.count);
Writeln('something shown?');
sqlwhereitems.add('(');
sqlwhereitems.add('(');
//vorwärts
If Forward then sqlwhereitems.add(Feldname+'>:P1')
//rückwärts
Else sqlwhereitems.add(Feldname+'<:P1');
sqlwhereitems.add(')');
sqlwhereitems.add('OR');
sqlwhereitems.add('(');
//vorwärts
if Forward then sqlwhereitems.add(Feldname+'=:P1 and ref>:P2')
//rückwärts
Else sqlwhereitems.add(Feldname+'=:P1 and ref<:P2');
sqlwhereitems.add(')');
sqlwhereitems.add(')');
Writeln('SQLwhereitems:');
Writeln(SQLwhereitems.commatext);
End;
End;
Regards
Gunther