Use of ?get diagnostics'?

2019-09-21 Thread Thiemo Kellner

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


smime.p7s
Description: S/MIME Signature


Re: Use of ?get diagnostics'?

2019-09-21 Thread Andrew Gierth
> "Thiemo" == Thiemo Kellner  writes:

 Thiemo> Hi all
 Thiemo> I try to create a function (code at
 Thiemo> https://pastebin.com/mTs18B90)

Paste sites are for IRC, on the mailing list you should always attach
the necessary details to your message.

 Thiemo> using 'get diagnostics' to retrieve the number of affected
 Thiemo> rows. However, it throws

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

line 44 of your paste:  V_TEXT := V_TEXT || ROW_COUNT || ' row.';

should be V_ROW_COUNT, I suspect. Likewise line 46.

(The CONTEXT lines of the error message would have identified the
offending line of the function for you.)

-- 
Andrew (irc:RhodiumToad)