Re: syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: cyw(at)dls(dot)net
Cc: "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;
Date: 2008-09-10 00:46:10
Message-ID: 11253.1221007570@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<cyw(at)dls(dot)net> writes:
> I am getting an error on "GET DIAGNOSTICS " statement in a PL/SQL function
> below.

> CREATE OR REPLACE FUNCTION test(lid int, OUT nid int) AS $$
> DECLARE
> road_row road%ROWTYPE;
> BEGIN
> SELECT * INTO road_row FROM road WHERE link_id=lid;
> GET DIAGNOSTICS xcount = ROW_COUNT;

You need to have declared xcount as an integer variable.

> The exact error message is:
> ERROR: syntax error at or near "xcount" at character

Hmm, not the most friendly error, I agree ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2008-09-10 00:51:43 Re: PostgreSQL TPC-H test result?
Previous Message Darren Weber 2008-09-09 23:43:24 OSX build of PostgreSQL 8.3.3 with macports