Quote
In article <41dlhq$...@newsbf02.news.aol.com> ebin...@aol.com "EBinary" writes:
> Has anyone found a way to do "Outer" joins on paradox tables using SQL.
[snip]
Yes - I've just been converting a pile of PdoxDOS code to Delphi (yawn)
and it works no problem. Because of the non-SQL standard names allowed
in Pdox, you have to follow the local SQL naming rules carefully - plus
the error messages are useless. Please find below examples of some of
the common Pdox features and Delphi/local SQL equivalents, and a
procedure 'doQuery' which I use for PAL conversions:
Pdox feature: _collno! on "Collection No"
Delphi LocalSQL equivalent LEFT OUTER JOIN:
doQuery('SELECT a."Source", a."Collection No", a."Coin No",'+
' a."Amount", a."Source Name",'+
' b."Name" AS Collection_Name'+
' FROM ":work:answer.db" a '+
' LEFT OUTER JOIN ":covyear:specials" b' +
' ON a."Collection No" = b."No"');
Pdox feature: Check on "Coin No", CALC SUM ALL on "Collected":
Delphi LocalSQL equivalent:
doQuery('SELECT w."Coin No", SUM(w."Collected") AS Number' +
' FROM ":covwork:cash" w' +
' GROUP BY w."Coin No" ');
Pdox feature: Creating new blank columns with CALC 0 AS ...:
Delphi LocalSQL equivalent:
doQuery('SELECT p."No", p."Name", p."Qty in Bag",' +
' a."Number" * p."Value" AS Amount, ' +
' 0 AS Full_Bags, 0 AS Remainder,' +
' a."Number"' +
' FROM ":covperm:coinage" p, ":work:answer" a' +
' WHERE p."No" = a."Coin No"');
Note that LocalSQL will NOT allow: 0 AS "Non Standard SQL Name" ...
procedure TWeeklyReportsForm.doQuery(QueryString: String);
begin
with MyQuery do begin
Close;
SQL.Clear;
SQL.Add(QueryString);
Open;
end;
with MyBatchMove do begin
Source := MyQuery; {Move to Answer}
Destination := AnswerTable;
Mode := batCopy;
Mappings.Clear;
Execute;
end;
end;
I'm sure there are many more examples - come on, Dr.Bob, there's an
article in it for you!
John
+---------------------+------------------------------------------------------+
John P.McCreesh | Internet: jpmccre...@pines.demon.co.uk
Forbo-Lancaster Ltd. | X.400: c=GB,a=CWMAIL,p=FORBO,g=John,s=McCreesh
Lancaster, England | Voice: +44 (0) 1524 65222 Fax: +44 (0) 1524 61638