On Wed, Feb 24, 2010 at 5:54 PM, eternelmangekyosharingan
<eternelmangekyosharin...@gmail.com> wrote:
> I'm sorry but I don't get your answer.
> Can you provide further explanations, please ?

Well, it is entirely possible that I have not understood your
question, and from Igor and Dan's answers, it seems even more so that
I am on the wrong track understanding what you are asking.

My point was, why should sqlite3 return 'text' as typeof(a) when you
are doing the following?

insert into t1 values(123456789.123456789);

Per SQL rules, text has to be quoted in single-quotes, else it is
interpreted as a column name or an expression.

sqlite> create table t1(a);
sqlite> insert into t1 values (123);
sqlite> insert into t1 values (231.3453);
sqlite> insert into t1 values ('231.4325');
sqlite> insert into t1 values (two thirty one);
SQL error: near "thirty": syntax error
sqlite> insert into t1 values (two);
SQL error: no such column: two
sqlite> select * from t1;
a
----------
123
231.3453
231.4325
sqlite> select typeof(a), a from t1;
typeof(a)   a
----------  ----------
integer     123
real        231.3453
text        231.4325

The above behavior is so basic and consistent with both how SQL and
sqlite behave that I don't understand where your query is coming
from... given that folks much more competent than I have replied with
all manner of complex answers, actually now I am eager to know what
exactly you are asking. It will help me understand what I
misunderstood about your question.




>
> On Thu, Feb 25, 2010 at 12:40 AM, P Kishor <punk.k...@gmail.com> wrote:
>
>> On Wed, Feb 24, 2010 at 5:22 PM, eternelmangekyosharingan
>> <eternelmangekyosharin...@gmail.com> wrote:
>> > Hello all,
>> >
>> > I create the following table:
>> > sqlite> create table t1(a);
>> > sqlite> insert into t1 values(123456789.123456789);
>> >
>> > I ran the following commands:
>> > sqlite> select * from t1;
>> > 123456789.123457
>> > sqlite> select typeof(a) from t1;
>> > real
>> >
>> > What I expected to get is:
>> > sqlite> select * from t1;
>> > 123456789.123456789
>> > sqlite> select typeof(a) from t1;
>> > text
>> >
>> > since the conversion of 123456789.123456789 to real induce some loss.
>> >
>> >
>> > Can someone help me out to understand the dynamic typing of sqlite ?
>> >
>>
>>
>> sqlite> create table t1(a);
>> sqlite> insert into t1 values ('123456789.123456789');
>> sqlite> select * from t1;
>> a
>> -------------------
>> 123456789.123456789
>> sqlite> select typeof(a) from t1;
>> typeof(a)
>> ----------
>> text
>> sqlite> insert into t1 values (123456789.123456789);
>> sqlite> select * from t1;
>> a
>> -------------------
>> 123456789.123456789
>> 123456789.123457
>> sqlite> select typeof(a) from t1;
>> typeof(a)
>> ----------
>> text
>> real
>> sqlite>
>>
>>
>>





-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to