2009/12/15 Cariotoglou Mike <[email protected]>:
> I checked in the bug database, and this does not seem to have been
> reported, and IMHO it is definitely a bug.
> workarounds exist,as pointed out by me and others. still, I would like
> to hear from the core team whether this is
> recognized as a bug, and will be dealt with at some point in time.
> btw, I would have liked to post a script demonstrating the bug, but I do
> not think this is possible, due to the fact that the
> command-line sqlite does not handle parametric statements, or at least I
> don't know how to write one :)
>
I am unable to reproduce your problem (version 3.6.11):
//
// create table item_artist( artist_id integer, data text );
// create table artists( artist_id integer, data text );
// insert into artists values( 1, 'a1_pic1' );
// insert into artists values( 2, 'a1_pic2' );
// insert into item_artist values( 1, 'a1_item1' );
// insert into item_artist values( 2, 'a2_item1' );
// insert into item_artist values( 2, 'a2_item2' );
#include "stdafx.h"
#define SQLITE_PRIVATE
#include "sqlite3.c"
int _tmain(int argc, _TCHAR* argv[])
{
int cnt;
int dbStatus;
sqlite3* dbH;
sqlite3_stmt* stmt;
dbStatus = sqlite3_open( "tstBind.db", &dbH );
while( fscanf( stdin, "%d", &cnt ) )
{
char* sql = "select * from ( select *,"
"(select count(*) from ITEM_ARTIST where "
"ARTIST_id=artists.artist_id) CNT from ARTISTS ) where "
"cnt = :a;";
const char* tail;
if( 0 == cnt )
{
exit(0);
}
dbStatus = sqlite3_prepare_v2( dbH, sql, strlen( sql ), &stmt,
&tail );
if( SQLITE_OK != dbStatus )
{
printf( "%s\n", sqlite3_errmsg( dbH ) );
}
dbStatus = sqlite3_bind_int( stmt, 1, cnt );
if( SQLITE_OK != dbStatus )
{
printf( "%s\n", sqlite3_errmsg( dbH ) );
}
while( SQLITE_ROW == ( dbStatus = sqlite3_step( stmt ) ) )
{
printf( "%s ", sqlite3_column_text( stmt, 0 ) );
printf( "%s ", sqlite3_column_text( stmt, 1 ) );
printf( "%s\n", sqlite3_column_text( stmt, 2 ) );
}
sqlite3_finalize( stmt );
}
sqlite3_close( dbH );
return 0;
}
On executing if I enter 1 I get
1
1 a1_pic1 1
and if 2, then
2
2 a2_pic1 2
which all looks ok
Regards,
Simon
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users