I am executing an alter table command and adding a new column with default value it is showing an error.
CREATE OR REPLACE FUNCTION test_function() RETURNS void AS $$
BEGIN
EXECUTE format('ALTER TABLE viminfo ADD COLUMN vimtype character varying(64) NOT NULL DEFAULT (NA), ADD COLUMN vimname character varying(255) NOT NULL DEFAULT (NA)');
END
$$language plpgsql;
Error: ERROR: column "na" does not exist
What is wrong I am doing here.. Thanks
execute? You can write the DDL statement directly in the function without the use of dynamic SQL.