
July 2nd, 2009, 10:25 PM
|
|
Registered User
|
|
Join Date: Apr 2009
Posts: 4
Time spent in forums: 2 h 4 m 56 sec
Reputation Power: 0
|
|
|
Type casting view columns
Hello,
I have one view which relies on others. Basically a bunch of views that each perform one step of a calculation and one final view which combines the final result
All of the calculations deal exclusively with integers but the final view is spitting out the columns with the type Numeric instead of Integer. To fix this I am trying to cast it as integer in the final view.
The current result of the view for the column "played_home" gives me 4 rows with values 0, 1, 1 and 2. Yet when I try to cast this I am getting this error:
ERROR: cannot change data type of view column "played_home"
I have tried casting using two different syntax (both give the same error)
cast(sum(played_home) as integer) AS played_home
sum(played_home)::integer AS played_home
BTW, if you're curious, this is a problem in my application code because I am using SQLAlchemy, an ORM in Python, and it is giving me a string wrapped in a Decimal function rather than the native integer data type. So I get Decimal("2") instead of just 2.
Any help would be appreciated, thanks!
|