Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RAISE NOTICE not appearing on screen

Tags:

postgresql

I have the following trigger that checks if space used > quota and increments the quota by 5. The quota is successfully incremented but the RAISE NOTICE does not appear on the screen.

 CREATE OR REPLACE FUNCTION checkspaceused() RETURNS TRIGGER AS $cssubscription$
 DECLARE
 new_spaceused INTEGER; 
 new_id INTEGER; 
 new_quota INTEGER ;
 BEGIN
    IF(TG_OP='UPDATE') THEN
        IF NEW.spaceused > NEW.quota THEN
        RAISE NOTICE 'Limit breached';
        UPDATE subscription SET quota = NEW.spaceused + 5 where u_id = NEW.u_id; 
        END IF ; 

    END IF;

RETURN NEW; 
END;
$cssubscription$ LANGUAGE plpgsql;
CREATE TRIGGER checkspaceused AFTER UPDATE ON subscription FOR EACH ROW EXECUTE PROCEDURE checkspaceused();

Help please.


2 Answers

Do this, before you execute the function..

SET client_min_messages TO NOTICE;

... and then check the Messages tab if using pgAdmin

like image 105
blissweb Avatar answered Oct 22 '25 22:10

blissweb


Check the value for client_min_messages in your session - it should be NOTICE or later to see notices.

like image 36
Milen A. Radev Avatar answered Oct 22 '25 22:10

Milen A. Radev