You misunderstand binding.  You use it like this -

   sql - "SELECT name FROM customers WHERE cust_id = ?";
   this_cust_id - "CUST1275";

   sqlite3_prepare_v2(...);

   sqlite3)bind_text(..., 1, this_cust_id, ...);

You bind a value to the data represented by the ?.  Then you reuse the 
compiled SQL by successively binding data values to it.

If you are not re-using the compiled SQL you do not use bind.

Mahalakshmi.m wrote:
>  
> 
> Hi,
> 
>  
> 
> My table looks like:
> 
>  
> 
> Id                Name
> 
> 1                     1aaa
> 
> 2                     01345
> 
> 3                     1asdf
> 
>  
> 
>  
> 
> I want the statement to be like:
> 
> "SELECT id, Name FROM MUSIC WHERE Name >= '1a'  LIMIT 1;"
> 
> But using prepare I could not able to get the desired statements.
> 
> I want to bind unsigned short as text. i.e, If the Unsighed short is 0x0061
> I want to bind it as 'a'.
> 
>  
> 
> My Prepare statement is as follows:
> 
>  
> 
> Unsigned char u8_ClassificationCode=1;
> 
> Unsigned short u16_Input=0x0061;
> 
> if ( sqlite3_prepare(gpst_SqliteInstance,"SELECT id, Name FROM MUSIC WHERE
> Name >= '%d%c'  LIMIT 1;",-1,&pst_SearchPrepareStmt,0)!= SQLITE_OK) 
> 
> {
> 
>             return SQLITE_DB_ERROR;
> 
> }
> 
> else
> 
> {
> 
>             sqlite3_bind_int(pst_SearchPrepareStmt,1,u8_ClassificationCode);
> 
>             sqlite3_bind_text16(pst_SearchPrepareStmt,2,(char
> *)u16_Input,-1,SQLITE_STATIC);
> 
> }
> 
>  
> 
> For the above the return status of sqlite3_prepare is success  but not
> properly binded.
> 
>  
> 
> Please help me to solve this.
> 
>  
> 
> Thanks & Regards,
> 
> Mahalakshmi.M
> 
>  
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to