I have a column of type object, and i need to make it from another object type, (the table is empty )
i tried to do :
ALTER TABLE invoice_history ALTER COLUMN invoice_info TYPE invoice USING (trim(invoice_info)::invoice);
ERROR: function pg_catalog.btrim(invoice_item) does not exist LINE 1: …ory ALTER COLUMN invoice_info TYPE invoice USING (trim(invoi… ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
and :
ALTER TABLE invoice_history ALTER COLUMN invoice_info TYPE invoice USING (invoice_info::invoice)
given this error :
ERROR: cannot cast type invoice_item to invoice LINE 2: …UMN invoice_info TYPE invoice USING (invoice_info::invoice…
what i should do ? and how can it changed ?
Advertisement
Answer
If the table is empty (or you do not care about the column value conversion) use just null
, e.g.:
alter table invoice_history alter invoice_info type invoice using null;