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.
Change data types in Design viewLocate the field that you want to change, and select a new data type from the list in the Data Type column. Save your changes.
The altered view replaces the existing view, so you cannot modify specific columns in a view. A view is a virtual table based on the result set of a SELECT query or a UNION of such queries. For more details on views, see Defining and Using Views.
ALTER VIEW [ IF EXISTS ] name ALTER [ COLUMN ] column_name SET DEFAULT expression ALTER VIEW [ IF EXISTS ] name ALTER [ COLUMN ] column_name DROP DEFAULT ALTER VIEW [ IF EXISTS ] name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER } ALTER VIEW [ IF EXISTS ] name RENAME [ COLUMN ] column_name TO ...
If you want to change the data type of a view's columns, you have to drop it, then create it.
Version 9.2 docs
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With