?
Solved

Returning of affected rows when executing postgresql function (stored procedure)

Posted on 2006-03-22
3
Medium Priority
?
2,713 Views
Last Modified: 2012-05-05
Hi,


when executing a postgresql function/stored proc (like an update) I would like to have as return value the number of affected rows. Could someone, please, help me?



Thanks,


DB
0
Comment
Question by:davyberroho
2 Comments
 
LVL 22

Accepted Solution

by:
earth man2 earned 2000 total points
ID: 16261285


create or replace function x returns integer is $$
declare
  number_of_rows integer := 0;
begin
  update table_y set col_x = default where col_z is null;
  GET DIAGNOSTICS number_of_rows = ROW_COUNT;
  return number_of_rows;
end;
$$ language plpgsql;
0
 
LVL 62

Expert Comment

by:gheist
ID: 16515295
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept earthman2 http:#16261285

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

gheist
EE Cleanup Volunteer
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Integration Management Part 2

839 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