Bernd Lehmkuhl wrote:
> 
> The actual table definition is :
> CREATE TABLE T_VWG_ABFALLVERZEICHNIS (SCHLUESSEL String, BESCHREIBUNG
String, BEMERKUNG String, ID_GUID String,
> IST_PAUSCHALIERT String, IST_KATEGORIE_ESK_BETRIEBSSTOF String);
> 
> SQLite version 3.7.16.2 2013-04-12 11:52:43
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> select schluessel, typeof(schluessel)
>    ...> from t_vwg_abfallverzeichnis
>    ...> where id_guid in ('BEE7F6108F02416FA0C9D5DC777DB172',
'6061A3864C2546C4A7DDA9FDB321459F');
> 1|integer
> 01 01|text
> sqlite>
> 
> I *expected* to gain TEXT affinity through the use of System.Data.SQLite
and it's strongly typed types (doppelt
> gemoppelt?), but apparently this is not totally effective. Maybe Joe
Mistachkin can say something about that?
> 

Using test suite infrastructure here (i.e. via Eagle), I get the following
results with a column of type "String":

set db1 [sql open -type SQLite {Data Source=test1.db;}]
sql execute -verbatim $db1 "CREATE TABLE t1 (x String);"
sql execute -verbatim $db1 "INSERT INTO t1 (x) VALUES (1);"
sql execute -verbatim $db1 "INSERT INTO t1 (x) VALUES ('02');"
sql execute -verbatim $db1 "INSERT INTO t1 (x) VALUES (?);" [list param1
Int32 3]
sql execute -verbatim $db1 "INSERT INTO t1 (x) VALUES (?);" [list param1
String 04]
sql execute -execute reader -format list $db1 "SELECT * FROM t1;"

        1 2 3 4

The leading zeros are being stripped from the '02' and '04' values by the
SQLite core native library itself, due
to the underlying type affinity of that column.  Declaring the columns to be
of type TEXT should make everything
work in the way you expect.

Repeating the same steps with a column type of "TEXT":

set db2 [sql open -type SQLite {Data Source=test1.db;}]
sql execute -verbatim $db2 "CREATE TABLE t2 (x TEXT);"
sql execute -verbatim $db2 "INSERT INTO t2 (x) VALUES (1);"
sql execute -verbatim $db2 "INSERT INTO t2 (x) VALUES ('02');"
sql execute -verbatim $db2 "INSERT INTO t2 (x) VALUES (?);" [list param1
Int32 3]
sql execute -verbatim $db2 "INSERT INTO t2 (x) VALUES (?);" [list param1
String 04]
sql execute -execute reader -format list $db2 "SELECT * FROM t2;"

        1 02 3 04

--
Joe Mistachkin

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

Reply via email to