I just create a new view as follows
CREATE OR REPLACE VIEW gettreelistvw AS
SELECT "CRM".groupid, 'pointrewarding'::text AS applicationid, "CM".menuid, "CM".menuname, "CM".levelstructure, "CM".moduleid, "CM".haschild, "CM".installed
FROM core_capabilitymap "CRM"
JOIN core_menus "CM" ON "CRM".menuid::text = "CM".menuid::text;
ALTER TABLE gettreelistvw
when i execute this error appear
ERROR: cannot change data type of view column "applicationid" from unknown to text
although I already cast the value of applicationid column to text. it's still recognized as unkown datatype
'pointrewarding'::text
The alternative method of postgres conversion also didn't work.
CAST('pointrewarding' AS TEXT)
How to solve this problem.
If you want to change the data type of a view's columns, you have to drop it, then create it.
CREATE OR REPLACE VIEW .... The new query must generate the same columns that were generated by the existing view query (that is, the same column names in the same order and with the same data types), but it may add additional columns to the end of the list.
Emphasis added.