I'm trying to run this sql which create a new type if is is not existed:
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'ai') CREATE TYPE ai AS (a text, i int);
I got an error at or near "if", I have trying to find out the answer but its no help. I tried this also but it still not work:
CASE (SELECT 1 FROM pg_type WHERE typname = 'ai') WHEN IS NULL THEN CREATE TYPE ai AS (a text, i int);
error near or at "CASE"
IFin SQL (at least in postgres).