Discussion:
IBScript
(too old to reply)
Victor Granados
2008-06-04 20:50:05 UTC
Permalink
I have a problem. This is the porcedure involving a IBScript:

function TFTraspaso.Anade_SQL_Traspaso(FUE1, DES1, CAN1, SIPER1, COD1, NOM1,
VFUE1, VDES1, PINI1, PFIN1 : String) : String;
Var
Apoyo1: String;
begin
Apoyo1:='insert into TRASPASO (FUE, DES, CAN, SIPER, COD, NOM, VFUE, VDES,
PINI, PFIN) values ('+FUE1+', '+DES1+', '+CAN1+', ';
Apoyo1:=Apoyo1+SIPER1+',
'+''''+COD1+''','+''''+NOM1+''','+''''+VFUE1+''','+''''+VDES1+''','+''''+PINI1+''','+''''+PFIN1+''');'+#13#10;
Anade_SQL_Traspaso:=Apoyo1;
end;

procedure TFTraspaso.BtnGuardarClick(Sender: TObject);
Var
STemp, Ap01, Ap02, Ap03, Ap04, Ap05, Ap06, Ap07, Ap08, Ap09, Ap10: String;
AnchoIBS: Integer;
begin
If DatosPrinc.CDSQTemp2.RecordCount>0 then
begin
STemp:='BATCH START;'+#13#10;
DatosPrinc.CDSQTemp2.First;
While not(DatosPrinc.CDSQTemp2.Eof) do
begin
Ap01:=EdAlmacen1.Text;
Ap02:=EdAlmacen2.Text;
Ap03:=DatosPrinc.CDSQTemp2.FieldByName('COD').AsString;
Ap04:=DatosPrinc.CDSQTemp2.FieldByName('NOM').AsString;
Ap05:=FloatToStrF(DatosPrinc.CDSQTemp2.FieldByName('CAN').AsFloat,ffFixed,10,2);
Ap06:=ExiMod1;
Ap07:=ExiMod2;
If CheckBox1.Checked then
begin
Ap08:=FechaPunto(LabFecIni.Caption);
Ap09:=FechaPunto(LabFecFin.Caption);
Ap10:='True';
end
else
begin
Ap08:=FechaPunto(DateToStr(now));
Ap09:=FechaPunto(DateToStr(now));
Ap10:='False';
end;
STemp:=STemp+Anade_SQL_Traspaso(Ap01,Ap02,Ap05,Ap10,Ap03,Ap04,Ap06,Ap07,Ap08,Ap09);
AnchoIBS:=Length(STemp);
If AnchoIBS>64000 then
begin
STemp:=STemp+'BATCH EXECUTE;'; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBTransScript1.StartTransaction;
ModuloModif.IBScript1.Script.Text:=STemp;
ModuloModif.IBScript1.ExecuteScript;
If ModuloModif.IBTransScript1.InTransaction then
ModuloModif.IBTransScript1.Commit; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBScript1.Script.Clear;
STemp:='BATCH START;'+#13#10;
end;
DatosPrinc.CDSQTemp2.Next;
end;
STemp:=STemp+'BATCH EXECUTE;'; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBTransScript1.StartTransaction;
ModuloModif.IBScript1.Script.Text:=STemp;
ModuloModif.IBScript1.ExecuteScript;
If ModuloModif.IBTransScript1.InTransaction then
ModuloModif.IBTransScript1.Commit; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBScript1.Script.Clear;
DatosPrinc.CDSQTemp2.EmptyDataSet;
DatosPrinc.CDSQTemp2.Close;
DatosPrinc.CDSQTemp2.Open;
BtnArriba.Click;
LabNomCod.Caption:='';
end
else
MessageDlg('¡No hay movimientos a guardar!', mtError, [mbOk], 0);
end;


I receive some data in a Client Data Set and I want data be written in a
table with an IBScript. The problem is that this procedure checks if the
script length is > 64000 (because if it is, a too long string error would be
sent). So it executes the script and begins another one. But the result of
this is that It writes in the table only the last part of the script. Why?.
Am I missing something?
Victor Granados
2008-06-05 00:28:01 UTC
Permalink
I think I found the problem, when the size of the line of the order you send
('Insert into Traspaso (FUE,DES....') is bigger than 256 I have that
problem. Is this normal?
Post by Victor Granados
function TFTraspaso.Anade_SQL_Traspaso(FUE1, DES1, CAN1, SIPER1, COD1,
NOM1, VFUE1, VDES1, PINI1, PFIN1 : String) : String;
Var
Apoyo1: String;
begin
Apoyo1:='insert into TRASPASO (FUE, DES, CAN, SIPER, COD, NOM, VFUE, VDES,
PINI, PFIN) values ('+FUE1+', '+DES1+', '+CAN1+', ';
Apoyo1:=Apoyo1+SIPER1+',
'+''''+COD1+''','+''''+NOM1+''','+''''+VFUE1+''','+''''+VDES1+''','+''''+PINI1+''','+''''+PFIN1+''');'+#13#10;
Anade_SQL_Traspaso:=Apoyo1;
end;
procedure TFTraspaso.BtnGuardarClick(Sender: TObject);
Var
STemp, Ap01, Ap02, Ap03, Ap04, Ap05, Ap06, Ap07, Ap08, Ap09, Ap10: String;
AnchoIBS: Integer;
begin
If DatosPrinc.CDSQTemp2.RecordCount>0 then
begin
STemp:='BATCH START;'+#13#10;
DatosPrinc.CDSQTemp2.First;
While not(DatosPrinc.CDSQTemp2.Eof) do
begin
Ap01:=EdAlmacen1.Text;
Ap02:=EdAlmacen2.Text;
Ap03:=DatosPrinc.CDSQTemp2.FieldByName('COD').AsString;
Ap04:=DatosPrinc.CDSQTemp2.FieldByName('NOM').AsString;
Ap05:=FloatToStrF(DatosPrinc.CDSQTemp2.FieldByName('CAN').AsFloat,ffFixed,10,2);
Ap06:=ExiMod1;
Ap07:=ExiMod2;
If CheckBox1.Checked then
begin
Ap08:=FechaPunto(LabFecIni.Caption);
Ap09:=FechaPunto(LabFecFin.Caption);
Ap10:='True';
end
else
begin
Ap08:=FechaPunto(DateToStr(now));
Ap09:=FechaPunto(DateToStr(now));
Ap10:='False';
end;
STemp:=STemp+Anade_SQL_Traspaso(Ap01,Ap02,Ap05,Ap10,Ap03,Ap04,Ap06,Ap07,Ap08,Ap09);
AnchoIBS:=Length(STemp);
If AnchoIBS>64000 then
begin
STemp:=STemp+'BATCH EXECUTE;'; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBTransScript1.StartTransaction;
ModuloModif.IBScript1.Script.Text:=STemp;
ModuloModif.IBScript1.ExecuteScript;
If ModuloModif.IBTransScript1.InTransaction then
ModuloModif.IBTransScript1.Commit; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBScript1.Script.Clear;
STemp:='BATCH START;'+#13#10;
end;
DatosPrinc.CDSQTemp2.Next;
end;
STemp:=STemp+'BATCH EXECUTE;'; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBTransScript1.StartTransaction;
ModuloModif.IBScript1.Script.Text:=STemp;
ModuloModif.IBScript1.ExecuteScript;
If ModuloModif.IBTransScript1.InTransaction then
ModuloModif.IBTransScript1.Commit; {** EJECUCION BATCH
UPDATE **}
ModuloModif.IBScript1.Script.Clear;
DatosPrinc.CDSQTemp2.EmptyDataSet;
DatosPrinc.CDSQTemp2.Close;
DatosPrinc.CDSQTemp2.Open;
BtnArriba.Click;
LabNomCod.Caption:='';
end
else
MessageDlg('¡No hay movimientos a guardar!', mtError, [mbOk], 0);
end;
I receive some data in a Client Data Set and I want data be written in a
table with an IBScript. The problem is that this procedure checks if the
script length is > 64000 (because if it is, a too long string error would
be sent). So it executes the script and begins another one. But the result
of this is that It writes in the table only the last part of the script.
Why?. Am I missing something?
Jeff Overcash (TeamB)
2008-06-05 06:40:43 UTC
Permalink
Post by Victor Granados
I think I found the problem, when the size of the line of the order you send
('Insert into Traspaso (FUE,DES....') is bigger than 256 I have that
problem. Is this normal?
Not that I am aware of, what happens if you remove the batch start and execute
and just do a normal script. There might be an undocumented limitation in the
batch stuff.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Victor Granados
2008-06-05 15:52:45 UTC
Permalink
Thank you very much.
Please, we need more documentation about IBScript, properities, methods,
events and examples

Victor Granados
Post by Jeff Overcash (TeamB)
Post by Victor Granados
I think I found the problem, when the size of the line of the order you
send ('Insert into Traspaso (FUE,DES....') is bigger than 256 I have that
problem. Is this normal?
Not that I am aware of, what happens if you remove the batch start and
execute and just do a normal script. There might be an undocumented
limitation in the batch stuff.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Jeff Overcash (TeamB)
2008-06-05 15:54:19 UTC
Permalink
Post by Victor Granados
Thank you very much.
Please, we need more documentation about IBScript, properities, methods,
events and examples
I meant undocumented in the API from InterBase. I do not write the
documentation for IBX. You want more examples put a QC in the documentation
section on it.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Loading...