Solved

Delphi: Get the number of affected Rows of an Update

Posted on 2004-08-31
2
2,393 Views
Last Modified: 2010-04-05
Hi all !
Using an Query-Object in Delphi 5, I want to get back the number of affected rows of an Update. How to do this.
I read about the "returning"-string but how to use it ?
Delphi:
query1.sql := 'update TABLE set id = 3 where port = 123';
query1.ExecSQL;
Showmessage(  [affected rows]  );
Thank you ...


0
Comment
Question by:delphistor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 125 total points
ID: 11940209
just lookup the rowsAffected-property after execSQL like

query1.ExecSQL;
Showmessage(inttostr(query1.rowsaffected));

from delphi help:

----------------------
Returns the number of rows operated upon by the latest query execution.

Delphi syntax:

property RowsAffected: Integer;

Description

Inspect RowsAffected to determine how many rows were updated or deleted by the last query operation. If no rows were updated or deleted, RowsAffected has a value of zero. RowsAffected will have a value of –1 if the execution of the SQL statement could not be executed due to an error condition. This latter situation would typically follow the raising of an exception.
---------------------

hope this helps

meikl ;-)

0
 

Author Comment

by:delphistor
ID: 11940614
Thank you meikl - it works !
A simple but effective solution !!!
delphistor....
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Base1 Encode/Decode 3 86
How to convert memory stream to PDF file 6 175
RESTRequest Parameter 4 54
How to insert .png images to TClientDataSet .cds file? 2 71
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question