Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine how many rows were updated

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,485
9
38
Scotland
www.ml-consult.co.uk
I am new to Postgres, so please bear with me.

I am connecting to a Postgres database via ODBC (my client happens to be Visual Foxpro, but that's not really relevant).

I would like to send an UPDATE to the server, and find out how many records were affected by the update. I see from the Postgres docs that "output" from UPDATE is the number of rows updated, which is exactly what I want. My question is: how can I get return that "output" to the client.

In SQL Server, I would query @@ROWCOUNT immediately after the UPDATE. I need to know the Postgres equivalent of that.

Thanks in advance.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

I'm surprised I didn't get an answer to this question. It seems a fairly simple issue, and I know that there are plenty of Postgres experts in this forum.

Did I not explain the problem properly? Does anything in my question need clarifying?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi

Please note, taht you question also involves Visual FoxPro and ODBC. For example I worked with PostgreSQL, but I used it with Kylix and dbExpress components. There was abit different :
Code:
[b]procedure[/b] updater;
  [b]var[/b] dset: TSQLDataSet;
      res: Integer;
[b]begin[/b]
  dset.CommandText := [i]'update table set field=value'[/i];
  res := dset.ExecSQL( true );
  Writeln( [i]'updated '[/i], res, [i]' rows'[/i]);
[b]end[/b];
As you can see, only the PostgreSQL knowledge will not help you. I would try in other related forums too, starting with forum706 ( ODBC ).

Feherke.
 

feherke,

Thanks for your reply. In fact, this is quite helpful.

Despite what you said, the problem isn't directly relate to FoxPro. That happens to be the language I use, but the whole point of ODBC is that works the same way in all client languages. I was looking for a more general answer.

However, if you are saying that Postgres itself doesn't have a function or procedure for returning the row count, that at least tells me something useful. I was hoping for the equivalent of SQL Server's @@ROWCOUNT, but I suppose that kind of thing doesn't exist in Postgres.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

I know you from other Visual foxpro forums. This is
what I use :

GET DIAGNOSTICS <variable> = ROW_COUNT
RETURN <variable>



Michael Kopljan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top