2009/11/11 TTTTT <erlichk...@gmail.com>:
>
> i think i understand why it doesnt work for select *..
>
> because sqlite_step executes one row at time.. so after i prepare SELECT * ,
> i need to use sqlite_step as many times as table i`m selecting from has rows
> (in this case 3 times)..
> so i made another function that looks like this:
>
>
>
> bool create2 (char * command)
>
> {
> sqlite3_stmt * statement2;
>
> if ( sqlite3_prepare (db, command, -1, &statement2, 0) != SQLITE_OK )
>        {
>                int err = sqlite3_prepare (db, command, -1, &statement2, 0);
>                const char * pErr = sqlite3_errmsg (db);
>                printf ("\nError %d occured! \n %s", err, pErr  );
>                return 1;
>        }
> int i;
> for (i=0; i<=3; i++)
> {
>        int smth= sqlite3_step (statement2);
>        printf ("\n command= %s result code = %d \n",command, smth);
> }

why not:
    int smth = sqlite3_step (statement2);
    while( smth == SQLITE_ROW )
    {
        printf( "\n command= %s result code = %d \n", command, smth );
        smth = sqlite3_step (statement2);
    }
so that it will work no matter how many rows

>        sqlite3_reset (statement2);
>        sqlite3_finalize (statement2);
>
>        return 0;
> }
>
>
>
> and finaly i get SQLITE_DONE but it still doesnt show me table i have
> selected...

See http://www.sqlite.org/c3ref/column_blob.html

>
>
> do i need to use prepare function for each command? if so, isnt then
> function select_statement better to use?

You are using prepare for each command...

>
>

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

Reply via email to