Iulian Musat wrote:
Hello everybody !
First of all I have to say that I'm a fairly new user of SQLite, so be
kind :-)
The problem is with the "round" function: the result have a decimal
point even if the second argument is zero (the default):
sqlite> select round(1.234);
1.0
sqlite> select round(1.234,0);
1.0
I'm not sure if this shouldn't produce '1' instead of '1.0'.
The reason for bringing this up is the resulted storage class in a
statement like this:
INSERT INTO tableint SELECT ROUND(some_expression) FROM other_table;
I know that in theory this shouldn't matter for SQLite, but I suppose
that some queries would be more efficient if the storage class is
INTEGER for the columns involved (please tell me if I'm wrong here).
So, here are the questions:
1. If you feel that round should behave this way, how do I submit a
patch. Not a lot of modifications nor terrible smart (basically some
work done at the end of roundFunc from func.c), but I'm also curios
how one can submit patches (sorry if I missed this info from sqlite.org).
See section Contributed Code at http://www.sqlite.org/copyright.html for
a start.
2. Is there a way to find the storage class for a particular field
from a particular row of a table?
I'm not sure for example if the next statements will produce the same
storage class:
create tableint (i integer);
insert into tableint values(1);
insert into tableint values(1.0);
insert into tableint values(round(1));
You can use the typeof() function to get the type (storage class) of a
field.
select typeof(round(1.234));
You can use the cast(x as type) syntax to change the type of the round
result to integer.
select cast(round(1.234) as integer);
HTH
Dennis Cote
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------