How to check if a row exists in a PostgreSQL stored procedure?

前端 未结 2 1323
醉梦人生
醉梦人生 2020-12-29 08:05

I writing a stored procedure in postgres where I need to check if a row exists then act accordingly. something along the line.

IF SELECT * FROM foo WHERE x =         


        
2条回答
  •  别那么骄傲
    2020-12-29 08:20

    Or even simpler with EXISTS:

    IF EXISTS (SELECT 1 FROM foo WHERE x = 'abc' AND y = 'xyz') THEN
        ....
    END IF;
    

提交回复
热议问题