Values can be parameterized for the core DML statements SELECT
, INSERT
, UPDATE
, and DELETE
.
But identifiers (or syntax elements) cannot be parameterized anywhere in SQL. In PL/pgSQL you can use dynamic SQL with EXECUTE
like Anton suggested. I.e., concatenate the whole command as string and then execute. See:
Optionally use format()
for convenience:
EXECUTE format('ALTER TABLE %I ALTER COLUMN company_uuid SET NOT NULL', _r.table_name);
With the %I
specifier for identifiers, unless _r.table_name
is already quoted properly. See: