Select with cast (numeric as decimal) works, but view creation does not

0

Good morning everyone!

I currently work with postgresql and I'm doing a database migration, and I need to create a view of my old database tables. Well, I need the number columns to round with 15.3 but I'm finding a problem that I can not figure out.

The select works:

select cast(15.2547 as decimal(15,3)) as quantidade_medida_estatistica

Creating the view does not work:

create or replace view teste as select cast(15.2547 as decimal(15,3)) as quantidade_medida_estatistica

The error returned is:

  

ERROR: Can not change column data type from numeric (15,4) to numeric (15,3) view

Thanks for all the help!

    
asked by anonymous 22.09.2016 / 15:24

1 answer

0

I found the solution and explanation for my problem in the answer to this topic: link .

Basically, I can not perform a CREATE OR REPLACE VIEW by changing the type of a column. For these cases it is necessary to perform a DROP view and then a CREATE view.

    
15.02.2017 / 22:56