Problem with fetching info IBDAC 4.1
Posted: Wed 28 Dec 2011 15:22
Problem extracting info from the table. Delphi 2007
This code hits the table MOVTOS_PR 3 times I will put a number to indicate the times and where it is being hit.
The problem that Im having is that in hit number 3 I do not get a valid date from the table this is the reason for the code where a validate the year 1899-12-30. But I dont understand way is this happening.
In hit number 1 the table is open in this manner:
Hit number 2 only deletes a record that is in the dataset of hit number 1.
Until this moment all is ok.
Hit number 3 gets the records in this manner:
It does get records because the (if qseek) vallidates if there are records or not.
Then i move the pointer to the last record and extract the field fecha of type datetime. But I dont get a valid Date or the info that corresponds to the last record.
I added 2 variables one of type string sfecha and the other of type datetime dfech when dfech gets the info I see in debug mode 0 when i go to see the value for sfecha a get 1899-12-30 the info in the table for that record is 2011-12-26.
Can some one please help me.
Thanks, in davance.
Ramiro
Code: Select all
sSQLs := 'Select Socio, Caja, Recibo, Cantidad, Saldo, TipoPrest, '+
'IDPagare, TipoMov '+
'From Movtos_PR '+
'Where (IDRECIBO = '+InttoStr(xIDRECIBO)+') '+
'Order By Fecha '
//Hit number 1
GetRecord(QSMovtosPR, sSQLs, False);
if not QSMovtosPR.Eof then
Begin
While Not QSMovtosPR.Eof Do
Begin
nPagare := QsMovtosPR.FieldByName('IDPagare').AsInteger;
nCantPR := QSMovtosPR.FieldByName('CANTIDAD').AsCurrency;
cTipoPR := QSMovtosPR.FieldByName('TIPOMOV').AsString;
sSQLs := 'Select * From Pagares '+
'Where (IDPagare = '+IntToStr(nPagare)+')';
if qSeek(sSQLs) then
SePago := dm.Master.FieldByName('Pagado').AsBoolean;
dm.Master.Close;
// Hit number 2
sSQLs := 'DELETE FROM MOVTOS_PR '+
'WHERE (IDPAGARE = '+IntToStr(nPagare)+') AND '+
'(IDRECIBO = '+InttoStr(xIDRECIBO)+')';
RunSql(sSqls);
[color=red]// Hit number 3
sSQLs := 'Select * From Movtos_PR '+
'Where IDPagare = '+IntToStr(nPagare)+' '+
'Order By FECHA, IDMOVTOPR';
if qSeek(sSQLs) then
begin
dm.Master.Last;
dFech := dm.Master.FieldByName('Fecha').AsDateTime;
sFecha := FormatDateTime('yyyy-mm-dd', dm.Master.FieldByName('Fecha').AsDateTime);
if sFecha <= '1899-12-30' then
begin
dm.Master.Prior;
dFech := dm.Master.FieldByName('Fecha').AsDateTime;
sFecha := FormatDateTime('yyyy-mm-dd', dm.Master.FieldByName('Fecha').AsDateTime);
end;
end;
dm.Master.Close;[/color]
//Saldo Corregido en Pagares
sSQLs := 'UPDATE PAGARES SET Saldo = Saldo + '+CurrToStr(nCantPR)+', '+
'UltMov = ' + QuotedStr(sFecha)+' ';
The problem that Im having is that in hit number 3 I do not get a valid date from the table this is the reason for the code where a validate the year 1899-12-30. But I dont understand way is this happening.
In hit number 1 the table is open in this manner:
Code: Select all
Qry1.Options.BooleanDomainFields := True;
Qry1.Connection := Dm.ibConec;
Qry1.Sql.Clear;
Qry1.Sql.Text := sSql;
Qry1.Open;
Until this moment all is ok.
Hit number 3 gets the records in this manner:
Code: Select all
dm.Master.SQL.Clear;
dm.Master.SQL.Add(xQuery);
dm.Master.Options.DeferredBlobRead := True;
dm.Master.Options.StrictUpdate := False;
dm.Master.Open;
Then i move the pointer to the last record and extract the field fecha of type datetime. But I dont get a valid Date or the info that corresponds to the last record.
I added 2 variables one of type string sfecha and the other of type datetime dfech when dfech gets the info I see in debug mode 0 when i go to see the value for sfecha a get 1899-12-30 the info in the table for that record is 2011-12-26.
Can some one please help me.
Thanks, in davance.
Ramiro