I'm trying to add a field to a table dynamically. I created a function and pass field name and datatype that I would like to create:
CREATE OR REPLACE function "trustedforms2"."parametertest"("_pname" varchar)
AS $BODY$BEGIN
-- Routine body goes here...
ALTER TABLE byoung.formdata ADD COLUMN _pname varchar(255);
END$BODY$
LANGUAGE plpgsql
This always creates a field named "_pname" regardless of the value I pass. How do I get the function to evaluate the variable by value and not as a literal? I tried "_pname"
, '_pname'
, %1 %_pname
and either get an error or a field called "_pname".