Page 1 of 2
Know if a row has been affected FB 2.1
Posted: Sat 06 Dec 2008 10:39
by calou
Hello,
I would like to know how is it possible to know if one or serveral rows have been affected when doing insert update delete or other.
Thank you for help
Regards
Posted: Mon 08 Dec 2008 09:23
by Plash
You can use the RowsAffected property of TIBCQuery.
Posted: Wed 07 Jan 2009 15:10
by calou
Hello Plash
If i do 'insert or update into...' and a line is updated, RowsAffected = 0
How could be wrong?
Thank you for help
Posted: Wed 07 Jan 2009 15:24
by calou
Sorry
I do 'update or insert into...'
Regards
Posted: Wed 07 Jan 2009 20:33
by calou
To be more precise here is a piece of my code.
Code: Select all
if not frmMain.IBCTrnsctnWrt.Active then
begin
frmMain.IBCQryWrt.SQL.text:='update or insert into DATA_10MIN '
+'(NOM_PROJET, CONSTRUCTEUR, MODELE_TURBINE, REF_TURBINE_VALOREM, DATE_HEURE, PUISS_ACTIVE_PRODUITE,'
+'VITESSE_VENT_NACELLE,DIRECTION_VENT_NACELLE,TEMP_EXTERIEUR, TEMP_ROUL_MULTI1,TEMP_ROUL_MULTI2, TEMP_STATOR,'
+'TEMP_HUILE_MULTI, VITESSE_ARBRE_RAPIDE,V_SIMPLE_PRODUITE)'
+'VALUES(:NOM_PROJET, :CONSTRUCTEUR, :MODELE_TURBINE, :REF_TURBINE_VALOREM, :DATE_HEURE, :PUISS_ACTIVE_PRODUITE,'
+':VITESSE_VENT_NACELLE,:DIRECTION_VENT_NACELLE,:TEMP_EXTERIEUR, :TEMP_ROUL_MULTI1,:TEMP_ROUL_MULTI2, :TEMP_STATOR,'
+':TEMP_HUILE_MULTI, :VITESSE_ARBRE_RAPIDE,:V_SIMPLE_PRODUITE)'
+'matching(NOM_PROJET,DATE_HEURE,REF_TURBINE_VALOREM)';
frmMain.IBCTrnsctnWrt.StartTransaction;
frmMain.IBCQryWrt.Prepare;
frmMain.IBCQryWrt.ParamByName('NOM_PROJET').AsString:=prjt;
frmMain.IBCQryWrt.ParamByName('CONSTRUCTEUR').AsString:=cnstrctr;
.....
if frmMain.IBCQryWrt.RowsAffected>0 then
begin
...
If there is an insert RowsAffected is >0 but if there is an update RowsAffected=0
Regards
Posted: Wed 07 Jan 2009 20:39
by calou
Sorry
Before
if frmMain.IBCQryWrt.RowsAffected>0 then
i have frmMain.IBCQryWrt.Execute;
Posted: Thu 08 Jan 2009 09:33
by Plash
I am glad that the problem is solved.
Posted: Thu 08 Jan 2009 10:22
by calou
No the problem
is not solved!
I have done an error when i paste my code on the post.
The correct code is :
Code: Select all
if not frmMain.IBCTrnsctnWrt.Active then
begin
frmMain.IBCQryWrt.SQL.text:='update or insert into DATA_10MIN '
+'(NOM_PROJET, CONSTRUCTEUR, MODELE_TURBINE, REF_TURBINE_VALOREM, DATE_HEURE, PUISS_ACTIVE_PRODUITE,'
+'VITESSE_VENT_NACELLE,DIRECTION_VENT_NACELLE,TEMP_EXTERIEUR, TEMP_ROUL_MULTI1,TEMP_ROUL_MULTI2, TEMP_STATOR,'
+'TEMP_HUILE_MULTI, VITESSE_ARBRE_RAPIDE,V_SIMPLE_PRODUITE)'
+'VALUES(:NOM_PROJET, :CONSTRUCTEUR, :MODELE_TURBINE, :REF_TURBINE_VALOREM, :DATE_HEURE, :PUISS_ACTIVE_PRODUITE,'
+':VITESSE_VENT_NACELLE,:DIRECTION_VENT_NACELLE,:TEMP_EXTERIEUR, :TEMP_ROUL_MULTI1,:TEMP_ROUL_MULTI2, :TEMP_STATOR,'
+':TEMP_HUILE_MULTI, :VITESSE_ARBRE_RAPIDE,:V_SIMPLE_PRODUITE)'
+'matching(NOM_PROJET,DATE_HEURE,REF_TURBINE_VALOREM)';
frmMain.IBCTrnsctnWrt.StartTransaction;
frmMain.IBCQryWrt.Prepare;
frmMain.IBCQryWrt.ParamByName('NOM_PROJET').AsString:=prjt;
frmMain.IBCQryWrt.ParamByName('CONSTRUCTEUR').AsString:=cnstrctr;
.....
frmMain.IBCQryWrt.Execute;
if frmMain.IBCQryWrt.RowsAffected>0 then
begin
Thank you for help
Posted: Fri 09 Jan 2009 10:20
by Plash
We have fixed this problem. The fix will be included in the next build of IBDAC.
Posted: Fri 09 Jan 2009 10:42
by calou
Thank you for answer Plash.
If there is a way to obtain this build very quickly or to have a meaning to correct it because my application is bugged

and the data are not correctly sent in my database?
Regards
Posted: Mon 12 Jan 2009 08:25
by Plash
Please contact us by e-mail ibdac*devart*com, specify your license number and Delphi version.
Posted: Tue 20 Jan 2009 14:38
by calou
Hello,
With the new build how could we do to differentiate if an update or insert occurs?
Because i was not aware that FB should always do an update even if no data has changed?
So in this case RowsAffected return always 1 and i can't do the difference between an update or an insert.
Thank you for help
Regards
Posted: Wed 21 Jan 2009 17:35
by calou
up

Posted: Thu 22 Jan 2009 10:40
by Plash
In the next IBDAC build we will add separate properties RowsInserted, RowsUpdated, and RowsDeleted.
For a while, you can use old IBDAC build without the fix. In this build RowsAffected returns 1 when a row is inserted, and 0 when a row is updated.
Posted: Thu 22 Jan 2009 10:53
by calou
Thank you very much
