From: | Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com> |
---|---|
To: | Erik Jones <erik(at)myemma(dot)com> |
Cc: | Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: getting the number of rows affected by a query |
Date: | 2007-11-19 01:25:13 |
Message-ID: | 1195435513.11620.2.camel@neuromancer.home.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2007-11-16 at 09:28 -0600, Erik Jones wrote:
> On Nov 16, 2007, at 3:26 AM, Ow Mun Heng wrote:
>
> >
> > On Fri, 2007-11-16 at 10:22 +0100, Martijn van Oosterhout wrote:
> >> On Fri, Nov 16, 2007 at 09:00:46AM +0800, Ow Mun Heng wrote:
> >>> I usually write a function which gets/uses the GETS DIAGNOSTIC
> >>> ROW COUNT
> >>> parameter which will tell me how many rows were affected by the
> >>> query.
> >>>
> >>> Now, for this case, I'm not writing a function but merely using a
> >>> normal
> >>> SQL eg:
> >>
> >> The server provides the number of changed rows in its response. Like
> >> DELETE 2030. So check whatever you're using to run the commands.
> >>
> >
> > The question is on how to use this number to be inserted into a table
> > instead of just being informational.
>
> The specifics depend on what language you're using for your database
> access. Regardless, though, save the server's response in a variable
> and use that.
Turns out this is a 2 part question, for which I have 1 solved.
1. using perl DBI to pull from MSSQL to PG..
--> I found out I can use
my $ins_rows = $dbh_pg->do($query2) or die "prepare failed
$DBI::errstr";
2. using pure SQL (via pgagent jobs) to pull. This is the one which I've
yet to be able to solve w/o writing a function and using GET DIAGNOSTICS
ROW COUNT.
--> Is one able to use variables in pure SQL ? (eg: undel psql?)
Thanks
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-19 01:35:08 | Re: 8.3b2 XPath-based function index server crash |
Previous Message | Matt Magoffin | 2007-11-19 01:10:07 | Re: 8.3b2 XPath-based function index server crash |