Board index » delphi » Help- Trying to sort Paradox table

Help- Trying to sort Paradox table

I am trying to sort a Paradox 4.5 table by a date field. I am using
Delphi 2.
The attached document(Dos.txt) has the SQL code and the explanation of
what is happening which is I cannot have a SQL object set up for a table
and have parameters set up. I can have one or the other, not both.

Any help would be greatly appreciated.
My E-Mail is on the attached document.

Thanks;
Roly

[ SampleText.txt 1K ]
This is the SQL coding in the QBE

SELECT Delivery."DDate" , Delivery."ID" ,
 Delivery."DHours" , Delivery."SStops" ,
 Delivery."Misses" ,
 Delivery."Mistakes" , Delivery."UPPCs" ,
 Delivery."TWUNITS" ,
 Delivery."Accesory"
FROM "Delivery.DB" Delivery,
WHERE "DDate" >= :Date1 and "DDate" <= :Date2

This the button to run the test coding

procedure TForm1.Button1Click(Sender: TObject);
Var
D1,D2,S1:TDateTime;
begin

D1:=StrToDate(Edit1.text);
D2:=StrToDate(Edit2.text);

Query1.close;
Query1.Prepare;
Query1.Params[0].AsDateTime:= D1;
Query1.Params[1].AsDateTime:= D2;

Query1.open;
(Error occurs after open)

DbiMakePermanent(Query1.handle,'c:\pdoxwin\querytst\Q1Temp.db',true);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.Close;
end;

end.

The database is a Paradox 4.5 table and the index'd field is "DDate"

I set up two Parameters called "Date1" and "Date2" that are set to date type.

The problem I am having is that I can have the parameters or I can have the table registered in the QBE object. I cannot have both. If I set up the parameters and run the test code the database is lost from the QBE. If I put the database in and run the test code I loose the parameters. I do not see why I cannot set up a database and name two parameters and then use them to sort the database as in the SQL code above.

The error I get when I run the code with the parameters set is as follows and when I go check the QBE there is no database registered.

Project QueryTst.exe raised exception class EDBEngineError with message 'Invalid use of keyword. Token: WHERE. Line Number: 8. Proccess stoped hit run or step to continue.

Any hint as to what is going on would be a tremedous help.

Roly
roly_...@earthlink.net

 

Re:Help- Trying to sort Paradox table


Try writing the SQL in regular SQL not QBE Sql:

SELECT DDate, ID ,
 DHours , SStops ,
 Misses ,
 Mistakes , UPPCs ,
 TWUNITS ,
 Accesory
FROM  Delivery,
WHERE DDate >= :Date1 and DDate <= :Date2

Query1.ParamByName('Date1').AsDate := D1;
Query1.ParamByName('Date2').AsDate := D2;

--
Michael Glatz
mgl...@caiso.com

Quote
Roland Hughes wrote in message <366F54C3.21C56...@earthlink.net>...
>I am trying to sort a Paradox 4.5 table by a date field. I am using
>Delphi 2.
>The attached document(Dos.txt) has the SQL code and the explanation of
>what is happening which is I cannot have a SQL object set up for a table
>and have parameters set up. I can have one or the other, not both.

>Any help would be greatly appreciated.
>My E-Mail is on the attached document.

>Thanks;
>Roly

Re:Help- Trying to sort Paradox table


On Wed, 09 Dec 1998 20:57:40 -0800, Roland Hughes <roly_...@earthlink.net>
wrote:

[...]

Quote
>This is the SQL coding in the QBE

>SELECT Delivery."DDate" , Delivery."ID" ,
> Delivery."DHours" , Delivery."SStops" ,
> Delivery."Misses" ,
> Delivery."Mistakes" , Delivery."UPPCs" ,
> Delivery."TWUNITS" ,
> Delivery."Accesory"
>FROM "Delivery.DB" Delivery,
>WHERE "DDate" >= :Date1 and "DDate" <= :Date2

[...]

Quote
>Project QueryTst.exe raised exception class EDBEngineError with message
>'Invalid use of keyword. Token: WHERE. Line Number: 8. Proccess stoped
>hit run or step to continue.

From what I can see, your problem is in the SQL statement and hs nothing to
do with having or not having parameters. Look at that trailing comma in the
FROM clause. I would expect that misplaced comma to cause the error you
cite given the SQL statement as composed. The only time a comma should be
in that particular place is in a multi-table join, with a table name
following it. But instead of a table name, you have the word "WHERE", which
is an invalid use of a keyword (WHERE).

By simply deleting this errant comma, your SQL statement should work.

Here's an extra tip. When a filter criteria depends on a column's value
being between two comparison values (within a range), you can use the
BETWEEN predicate.

  SELECT Delivery."DDate" , Delivery."ID" ,
    Delivery."DHours" , Delivery."SStops" ,
    Delivery."Misses" ,
    Delivery."Mistakes" , Delivery."UPPCs" ,
    Delivery."TWUNITS" ,
    Delivery."Accesory"
  FROM "Delivery.DB" Delivery,
  WHERE ("DDate" BETWEEN :Date1 AND :Date2)

And, what is this "QBE object" of which you speak? Were you actually
referring to the TQuery object? Or to some third-party querying object?

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "What is success in this world? I would say
Technical Publications         it consists of four simple things: to live
INPRISE Corporation            a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi  from it all, to learn a lot."
                                                     -- Richard J. Needham

Other Threads