Subject | RE: SQL error code = -104 Unexpected end of command, from Delphi App |
---|---|
Author | |
Post date | 2014-01-08T23:53:34Z |
I thought I had it fixed by switching to a different TIBCQuery to insert a new record. That worked fine. However, the same problem exists when I try to alter the SQL in order to "filter" the result set in the grid.
The exact same error (exactly the same) happens when I close the query to alter the SQL. Code below:
try
if DM.qAR.State in [dsEdit, dsInsert] then DM.qAR.Post;
DM.qAR.Close;
Case cxRG.ItemIndex of
0: begin
DM.qAR.SQL.Text := 'Select * From AR ORDER BY DueDate, TransDate, PolNum, ARAMT;';
end;
1: begin
DM.qAR.SQL.Text :=
'Select M.CARRIERNO, M.CARRIER, M.POLNUM, M.INVOICENO, M.TRANSNO, M.TRANSDATE, ' +
'M.TRANSSOURCE, M.TRANSTYPE, M.PREMIUM_BEFORE, M.PREMIUM_AFTER, ARAMT, ' +
'(select distinct Sum(D.ARAMT) from AR D where (D.polnum = M.PolNum) and ' +
'(D.transdate = M.transdate)) as SUM_OF_ARAMT , ' +
'M.DUEDATE, M.ACCTGPERIOD, M.ACCTGPERIODID, M.BANK, M.CHECKNO, M.CHECKDATE, ' +
'M.ENTEREDBY, M.ENTEREDDATE, M.NOTES ' +
'From AR M ' +
'Where (M.aramt <> 0) and (select Sum(D.ARAMT) from AR D ' +
'where (D.polnum = M.PolNum) and (D.transdate = M.transdate)) <> 0 ' +
'ORDER BY M.DUEDATE, M.TRANSDATE, M.POLNUM; ' ;
end;
2: begin
DM.qAR.SQL.Text :=
'Select M.CARRIERNO, M.CARRIER, M.POLNUM, M.INVOICENO, M.TRANSNO, M.TRANSDATE, ' +
'M.TRANSSOURCE, M.TRANSTYPE, M.PREMIUM_BEFORE, M.PREMIUM_AFTER, ARAMT, ' +
'(select distinct Sum(D.ARAMT) from AR D where (D.polnum = M.PolNum) and ' +
'(D.transdate = M.transdate)) as SUM_OF_ARAMT , ' +
'M.DUEDATE, M.ACCTGPERIOD, M.ACCTGPERIODID, M.BANK, M.CHECKNO, M.CHECKDATE, ' +
'M.ENTEREDBY, M.ENTEREDDATE, M.NOTES ' +
'From AR M ' +
'Where (M.aramt <> 0) and (select Sum(D.ARAMT) from AR D ' +
'where (D.polnum = M.PolNum) and (D.transdate = M.transdate)) = 0 ' +
'ORDER BY M.DUEDATE, M.TRANSDATE, M.POLNUM; ' ;
end;
end; // Case
finally
DM.qAR.open;
end;