简体   繁体   中英

can't update a procedure in postgresql

I try to update a procedure in psql, the code gives no error:

  CREATE OR REPLACE FUNCTION public.decrement_user_followers()
    RETURNS trigger
    LANGUAGE plpgsql
    AS $function$ 
    BEGIN
      UPDATE users SET unit_followers = unit_followers - 1 WHERE id = OLD.user_id_followed;
      UPDATE users SET unit_following = unit_following - 1 WHERE id = OLD.user_id_follower;
    RETURN OLD;
    END $function$

But when I try to see the change \\df+ decrement_user_followers gives me the old code.
Any suggestions?

The ";" was missing at the end ... ahhh

CREATE OR REPLACE FUNCTION public.decrement_user_followers()
    RETURNS trigger
    LANGUAGE plpgsql
    AS $function$ 
    BEGIN
      UPDATE users SET unit_followers = unit_followers - 1 WHERE id = OLD.user_id_followed;
      UPDATE users SET unit_following = unit_following - 1 WHERE id = OLD.user_id_follower;
    RETURN OLD;
    END $function$;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM