Re: syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT; - Mailing list pgsql-general

From Tom Lane
Subject Re: syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;
Date
Msg-id 11253.1221007570@sss.pgh.pa.us
Whole thread Raw
In response to syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;  (<cyw@dls.net>)
List pgsql-general
<cyw@dls.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

pgsql-general by date:

Previous
From:
Date:
Subject: syntax error on: GET DIAGNOSTICS xcount = ROW_COUNT;
Next
From: "Merlin Moncure"
Date:
Subject: Re: PostgreSQL TPC-H test result?