SuperMurloc
SuperMurloc

Reputation: 209

cannot change data type of view column from numeric to numeric(4,1)

I'm trying to calculate a ratio with 1 decimal place. So I created a view using

create or replace view MyView
as
select cast(A/B as numeric(4, 1)) as ratio from MyTable;

A is int type and B is real number with 3 decimal places and I'm getting an error

cannot change data type of view column "ratio" from numeric to numeric(4,1)

Any idea how to fix this?

Upvotes: 2

Views: 4711

Answers (1)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125304

drop first:

drop view MyView;
create or replace view MyView as
select cast(A/B as numeric(4, 1)) as ratio 
from MyTable;

Upvotes: 4

Related Questions