Know if a row has been affected FB 2.1

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Know if a row has been affected FB 2.1

Post by calou » Sat 06 Dec 2008 10:39

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 08 Dec 2008 09:23

You can use the RowsAffected property of TIBCQuery.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 07 Jan 2009 15:10

Hello Plash

If i do 'insert or update into...' and a line is updated, RowsAffected = 0

How could be wrong?

Thank you for help

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 07 Jan 2009 15:24

Sorry

I do 'update or insert into...'

Regards

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 07 Jan 2009 20:33

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

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 07 Jan 2009 20:39

Sorry :oops:

Before
if frmMain.IBCQryWrt.RowsAffected>0 then

i have frmMain.IBCQryWrt.Execute;

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 08 Jan 2009 09:33

I am glad that the problem is solved.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Thu 08 Jan 2009 10:22

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 09 Jan 2009 10:20

We have fixed this problem. The fix will be included in the next build of IBDAC.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Fri 09 Jan 2009 10:42

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 12 Jan 2009 08:25

Please contact us by e-mail ibdac*devart*com, specify your license number and Delphi version.
Last edited by Plash on Wed 21 Jan 2009 10:59, edited 1 time in total.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Tue 20 Jan 2009 14:38

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

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Wed 21 Jan 2009 17:35

up :oops:

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 22 Jan 2009 10:40

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.

calou
Posts: 116
Joined: Tue 27 May 2008 12:46

Post by calou » Thu 22 Jan 2009 10:53

Thank you very much :)

Post Reply