A parameter represents a literal. You can't bind a column name. After
binding, your query is equivalent to

select 'ID','age','name' from tbl1 where ID=1;

>   The return value of sqlite3_step(stat) was SQLITE_ROW, but the
> values I got were 0,
>   why?

Because the value of the column is a string (the same string literal you
bound to the parameter), which gets converted to int, and since it
doesn't look like an integer it gets converted to zero.

> I think maybe sqlite3_bind() can not bind the column name.

Quite.

>    The reson I try to select by "select ?,?,?.. from table where ..."
> but not "select * from table where ..."

But why not

select ID, age, name where ...;

Igor Tandetnik

------------------------------

If you have that many columns but want queries with only some of them,
then it is a good indication that your schema is not normalized.  See
the wikipedia entry for some guidance:

 http://en.wikipedia.org/wiki/Database_normalization
Roger
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
    Thanks very much!
    Now my main problem is that: the time to get a whole record from a table
whit 200 columns
was too long, test in my embdded system it was about 80ms. The program is
follow:
         sqlite3_prepare(db, "select * from tbl1 where ID=id", -1,&stat,
0);   \\ ID was a primary key
         rc = sqlite3_step ( stat );
         if (SQLITE_ROW == rc)
         {
               ...........
               ...........\\ get column values
         }

     I want to optimize this interface to reduce the time of getting a whole
record,
     are there some advices?  or maybe the last way is  change the design to
reduce some columns.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to