PL/pgSQL IF Statement

PHOTO EMBED

Fri Aug 13 2021 20:35:22 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

do $$
declare
  selected_film film%rowtype;
  input_film_id film.film_id%type := 0;
begin  

  select * from film
  into selected_film
  where film_id = input_film_id;
  
  if not found then
     raise notice'The film % could not be found', 
	    input_film_id;
  end if;
end $$
Code language: PostgreSQL SQL dialect and PL/pgSQL (pgsql)
content_copyCOPY

https://www.postgresqltutorial.com/plpgsql-if-else-statements/