0

I'm trying to add a notice (or something similar) to a function that is executed on update by a trigger in PostgreSQL 9.6 db. I want to let the user who edited the table that something happened. I don't know is "NOTICE" is the proper RAISE (Why not "INFO"?).

The central question is: how I can add the raise notice argument after the update?

3
  • 1
    According to the documentation, INFO is information implicitly requested by the user, which is not appropriate in this case. Please describe what you mean by "add the raise notice argument". Mar 4 at 17:09
  • 1
    i thnik he wants to send to the user a mesage which updates the salary like here dbfiddle.uk/…
    – nbk
    Mar 4 at 17:18
  • Yes nbk, that did the job! Thanks! Mar 4 at 18:56
0

The problem can be, that level for messages is too high

so try this appproach

CREATE TABLE id ( "id1" INT)
INSERT INTO id VALUES (1)
1 rows affected
do
$$
declare
  newnumer int = 90;
begin
   
  UPDATE id SET id1 =  newnumer WHERE id1 = 1;
SET client_min_messages TO INFO;
  raise info   '"NOTICE" is the proper RAISE (Why not "INFO"?)' ;
        -- catch notification
      
end;
$$
language plpgsql;
SELECT * FROM id;
| id1 |
| --: |
|  90 |

db<>fiddle here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.