Drop postgresql trigger How to drop trigger, syntax and example. Syntax DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]; Example – Drop postgresql trigger DROP TRIGGER IF EXISTS customers_trigger ON customers CASCADE; DROP TRIGGER IF...
Create postgresql type Create table type, alter and drop type. Syntax and examples. Syntax CREATE TYPE type_name AS ( attribute_name_1 data_type, attribute_name_2 data_type, ... attribute_name_n data_type ); CREATE TYPE type_name AS ENUM ( [ 'label' [, ... ] ] ); Example...
LOOP Syntax and examples of conditional Loop – End Loop. CREATE OR REPLACE FUNCTION get_loop(in p_id numeric) RETURNS varchar AS $$ DECLARE j numeric; v_name varchar(50); BEGIN j:=0; FOR i in 1..p_id LOOP j:=j+1; v_name:='The count is: '||j; END LOOP; return...
Case Syntax and examples of conditional Case – When – Then – Else. CREATE OR REPLACE FUNCTION get_case(in p_name varchar(2)) RETURNS varchar AS $$ DECLARE v_name varchar(50); BEGIN CASE WHEN p_name = 'T' then v_name:='The name is TEST'; return v_name; ELSE...
In PostgreSQL, the IF-ELSIF-ELSE conditional statement allows you to execute different blocks of code based on certain conditions. This conditional statement is often used in PL/pgSQL, which is the procedural language supported by PostgreSQL. PL/pgSQL provides control structures like IF-ELSIF-ELSE to...