How to work with control structures in PostgreSQL stored procedures: Using IF, CASE, and LOOP statements | EDB

PHOTO EMBED

Fri Aug 13 2021 20:34:58 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

DO $$

DECLARE

  x integer := 10;

  y integer := 20;

BEGIN 

  IF x > y THEN

   RAISE NOTICE 'x is greater than y';

  END IF;



  IF x < y THEN

   RAISE NOTICE 'x is less than y';

  END IF;



  IF x = y THEN

   RAISE NOTICE 'x is equal to y';

  END IF;

END $$;
content_copyCOPY

https://www.enterprisedb.com/postgres-tutorials/how-work-control-structures-postgresql-stored-procedures-using-if-case-and-loop