BareFeetWare wrote:
> On 04/05/2010, at 3:14 AM, Stefan Keller wrote:
>
>   
>> But in SQLite if a view column comes from a function result or some 
>> computation, then the column type is NULL...!? It's not taking the 
>> result-type as mentioned in the manual
>> (http://www.sqlite.org/lang_select.html) - even when I try to do a CAST in 
>> the projection clause, like this:
>>
>>  SELECT id, name, CAST(salary + 10 AS INTEGER) "salaryplus10" FROM mytable;
>>
>> I mean that a VIEW should behave like a (read only) TABLE in any case.
>> => Is there a way to give such columns a type anyway?
>>     
>
> I've had the same issue. In the end I had to parse my view functions in my 
> own code and look for functions that give a particular type of result. So, 
> for instance, round() gives an integer, round(..., 2) gives a real, concat() 
> gives text. I also look for a cast(... as type) to use that declared type. 
> It's fiddly and I would have hoped SQLite would have at least declared the 
> type if a cast was present, but it seems not.
>
>   
A CAST expression could be assigned a declared type, but it would be 
difficult to implement it for expressions in general.  Not only would 
you have to declare a type for every function, but you'd have to do it 
for operators as well, and what type should A * B be if A is "SMALLINT" 
and B is "UINT"?  Should relational operators have a declared type of 
BOOLEAN?

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to