Maybe I didn't express the problem clearly. > e.g. if you have a text value, you use _text(), if you have an int, you > use _int() I just don't know what type I have, so I want to get the meta type of the column somebody defined. e.g. I'd like to use a bind routine to bind a variable t to a "?", but I don't konw this t is a string or a number or it is a object, so I want to know that the table is defined like "id(varchar)" ,then I will use sqlite3_bind_text; or it is defined like "id(integer)", then I will choose sqlite3_bind_int.
Jay A. Kreibich-2 wrote: > > On Thu, Feb 04, 2010 at 03:59:14PM +0800, gujx scratched on the wall: >> There is a table like this: > > >> Is there any way to resolve this? > > First off, you need to understand that columns do not have "types", > they have affinities. > > http://sqlite.org/datatype3.html > > Read this whole page. Several times. Make sure you understand it in > great detail. > > > > Second, you can put any type into (almost) any column, so it doesn't > matter. If the affinity is setup right, SQLite will usually do the > right thing. For example, if you have a column with numeric affinity > and you insert the text value '12', it will converted to an integer > before it is stored. > > Which bind function you use is usually dictated by what you have > (e.g. if you have a text value, you use _text(), if you have an int, > you use _int()), rather than the column you are placing it in. > SQLite will try its best to convert what you've given it into a > format that makes sense for the column, but if it can't, it will store > it in whatever format you sent. Which is more or less exactly the > position you'd be in if you wanted to do the conversion "by-hand." > > -j > > -- > Jay A. Kreibich < J A Y @ K R E I B I.C H > > > "Our opponent is an alien starship packed with atomic bombs. We have > a protractor." "I'll go home and see if I can scrounge up a ruler > and a piece of string." --from Anathem by Neal Stephenson > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/how-to-get-the-meta-type-of-a-column-tp27451326p27462879.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users