Use of ?get diagnostics'?

From: Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>
To: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Use of ?get diagnostics'?
Date: 2019-09-21 07:57:00
Message-ID: 20190921075700.Horde.7M0WmarMSSL6-CZvUSrg4Dg@webmail.gelassene-pferde.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

I try to create a function (code at https://pastebin.com/mTs18B90)
using 'get diagnostics' to retrieve the number of affected rows.
However, it throws

the following exception was thrown:
SQLSTATE: 42703
column "row_count" does not exist

when I test it with

drop table if exists TEST_EXECUTE_WO_RETURN_LOGGED;
create table TEST_EXECUTE_WO_RETURN_LOGGED(I bigint, C char(2));
commit;
select EXECUTE_WO_RETURN_LOGGED(
I_STATEMENT_TO_EXECUTE => $$insert into
TEST_EXECUTE_WO_RETURN_LOGGED(I, C) values (1, 'ab');$$,
I_LEVEL => 'LOG',
I_REPORT_ERRORS_ONLY => true
);

If you want to try out the code, be aware that it uses pglogger and
pgutils (both on SourceForge maybe not there in the version yet
needed, work is ongoing) such that you might want to strip the
respective calls.

I created another function using 'get diagnostics' that works - it is
part of pglogger. Code snipped

$body$
declare
C_LOGGING_LEVEL_PROPERTY_NAME constant text := 'LOGGING_LEVEL';
V_ROW_COUNT bigint;
begin
update PROPERTY
set PROPERTY_VALUE_STRING = I_LEVEL
where PROPERTY_NAME = C_LOGGING_LEVEL_PROPERTY_NAME;
get current diagnostics V_ROW_COUNT = ROW_COUNT;

I did not find the error I am making.

Kind regards

Thiemo

--
S/MIME Public Key: https://oc.gelassene-pferde.biz/index.php/s/eJuAUFONag6ofnH
Signal (Safer than WhatsApp): +49 1578 7723737
Handys: +41 78 947 36 21 | +49 1578 772 37 37
Tox-Id:
B7282A9E31D944DDAD1ECC5B33C36AAE80B32D119AB7391D602C937A65E8CA0625C495C5322B

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Gierth 2019-09-21 08:21:06 Re: Use of ?get diagnostics'?
Previous Message Morris de Oryx 2019-09-21 06:01:03 Re: citext, actually probably using extensions