Re: [sqlite] Unknown parameter for prepare_v2

2011-05-20 Thread Dev_lex

Forget my last post..
The error was that I didn't initialize pzTail to NULL...

That's ok :)



Dev_lex wrote:
> 
> 
> Simon Slavin-3 wrote:
>> 
>> 
>> On 19 May 2011, at 9:35am, Dev_lex wrote:
>> 
>>> I need to prepare the statement before to know the name of the table,
>>> but
>>> I'll find an other way..
 
> 
> I would like to do this :
> 
>   const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";
>> 
>> Instead of using a const, use a C string, or select one of a few
>> different consts.
>> 
>> But what your problem is really telling you is that those tables are
>> actually all one big table.  The thing you think of as a table name is
>> really just another column.
>> 
>> Simon.
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>> 
>> 
> 
> 
> Yeah, thanks, I've found another way to solve my problem.. this wasn't too
> hard ^^..
> 
> But now I've got a new problem, again with this function..
> 
> 
> I've create a structure in a header file (called init_handle) that
> contains the informations like sqlite3 *db // sqlite3_stmt *Stmt // ...
> 
> And in a .c file I've made a function that prepare a command, but I obtain
> an error..
> 
> 
> Here is the line :
> 
> if( sqlite3_prepare_v2(init_handle.db, zSql_stmt[i][j],
> strlen(zSql_stmt[i][j])+1, _handle.Stmt[i][j], init_handle.pzTail) !=
> SQLITE_OK )
>   {
>fprintf(stderr, "Can't prepare : %s\n",
> sqlite3_errmsg(init_handle.db));
>sqlite3_close(init_handle.db);
>exit(1);
>   }
> 
> And the error says : 
> 
> Can't create table : table DHSS already exists
> Can't prepare : near "create": syntax error
> 
> Do I have made a syntax error?
> 

-- 
View this message in context: 
http://old.nabble.com/Unknown-parameter-for-prepare_v2-tp31653746p31662807.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


Re: [sqlite] Unknown parameter for prepare_v2

2011-05-20 Thread Dev_lex



Simon Slavin-3 wrote:
> 
> 
> On 19 May 2011, at 9:35am, Dev_lex wrote:
> 
>> I need to prepare the statement before to know the name of the table, but
>> I'll find an other way..
>>> 
 
 I would like to do this :
 
   const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";
> 
> Instead of using a const, use a C string, or select one of a few different
> consts.
> 
> But what your problem is really telling you is that those tables are
> actually all one big table.  The thing you think of as a table name is
> really just another column.
> 
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 


Yeah, thanks, I've found another way to solve my problem.. this wasn't too
hard ^^..

But now I've got a new problem, again with this function..


I've create a structure in a header file (called init_handle) that contains
the informations like sqlite3 *db // sqlite3_stmt *Stmt // ...

And in a .c file I've made a function that prepare a command, but I obtain
an error..


Here is the line :

if( sqlite3_prepare_v2(init_handle.db, zSql_stmt[i][j],
strlen(zSql_stmt[i][j])+1, _handle.Stmt[i][j], init_handle.pzTail) !=
SQLITE_OK )
{
 fprintf(stderr, "Can't prepare : %s\n",
sqlite3_errmsg(init_handle.db));
 sqlite3_close(init_handle.db);
 exit(1);
}

And the error says : 

Can't create table : table DHSS already exists
Can't prepare : near "create": syntax error

Do I have made a syntax error?
-- 
View this message in context: 
http://old.nabble.com/Unknown-parameter-for-prepare_v2-tp31653746p31662252.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


Re: [sqlite] Unknown parameter for prepare_v2

2011-05-19 Thread Simon Slavin

On 19 May 2011, at 9:35am, Dev_lex wrote:

> I need to prepare the statement before to know the name of the table, but
> I'll find an other way..
>> 
>>> 
>>> I would like to do this :
>>> 
>>>   const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";

Instead of using a const, use a C string, or select one of a few different 
consts.

But what your problem is really telling you is that those tables are actually 
all one big table.  The thing you think of as a table name is really just 
another column.

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


Re: [sqlite] Unknown parameter for prepare_v2

2011-05-19 Thread Dev_lex

Oh ok..
Thanks a lot, I thought there was some way to do that..

I need to prepare the statement before to know the name of the table, but
I'll find an other way..

Thanks !


Martin Engelschalk wrote:
> 
> Hi,
> 
> you cannot bind the name of a table. Bind variables only work for Values 
> in the database, like you used in the VALUES('1', ?) - clause.
> Names of tables, columns or other items of the schema must be written in 
> the sql statement.
> You will have to build your statement (using sprintf() or similar) 
> before preparig it.
> 
> This is not uniqe to sqlite, but to SQL in general.
> 
> Martin
> 
> Am 19.05.2011 10:04, schrieb Dev_lex:
>> Hello,
>>
>> I've a little question about sqlite3_prepare_v2 :
>>
>> I would like to do this :
>>
>>const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";
>>
>>   if(ppStmt)
>>{
>>sqlite3_bind_parameter_name(ppStmt, "atest");
>>sqlite3_bind_blob(ppStmt, 2,, sizeof(blob),
>> SQLITE_TRANSIENT);
>>sqlite3_step(ppStmt);
>>sqlite3_finalize(ppStmt);
>>}
>>
>> So then I've just to bind values.. It works great for the second '?'
>> which
>> is a blob, so bind_blob(), but for the first one I don't really know what
>> to
>> use ?
>>
>> Maybe the '?' syntax is incorrect? I've not understood everything about
>> it..
>>
>> Regards
> ___
> 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/Unknown-parameter-for-prepare_v2-tp31653746p31653969.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


Re: [sqlite] Unknown parameter for prepare_v2

2011-05-19 Thread Martin.Engelschalk
Hi,

you cannot bind the name of a table. Bind variables only work for Values 
in the database, like you used in the VALUES('1', ?) - clause.
Names of tables, columns or other items of the schema must be written in 
the sql statement.
You will have to build your statement (using sprintf() or similar) 
before preparig it.

This is not uniqe to sqlite, but to SQL in general.

Martin

Am 19.05.2011 10:04, schrieb Dev_lex:
> Hello,
>
> I've a little question about sqlite3_prepare_v2 :
>
> I would like to do this :
>
>const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";
>
>   if(ppStmt)
>{
>sqlite3_bind_parameter_name(ppStmt, "atest");
>sqlite3_bind_blob(ppStmt, 2,, sizeof(blob), SQLITE_TRANSIENT);
>sqlite3_step(ppStmt);
>sqlite3_finalize(ppStmt);
>}
>
> So then I've just to bind values.. It works great for the second '?' which
> is a blob, so bind_blob(), but for the first one I don't really know what to
> use ?
>
> Maybe the '?' syntax is incorrect? I've not understood everything about it..
>
> Regards
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Unknown parameter for prepare_v2

2011-05-19 Thread Dev_lex

Hello,

I've a little question about sqlite3_prepare_v2 :

I would like to do this : 

  const char   *zSql = "INSERT INTO ?(ID, MyData) VALUES('1',?)";

 if(ppStmt)
  {
  sqlite3_bind_parameter_name(ppStmt, "atest");
  sqlite3_bind_blob(ppStmt, 2, , sizeof(blob), SQLITE_TRANSIENT);
  sqlite3_step(ppStmt);
  sqlite3_finalize(ppStmt);
  }

So then I've just to bind values.. It works great for the second '?' which
is a blob, so bind_blob(), but for the first one I don't really know what to
use ?

Maybe the '?' syntax is incorrect? I've not understood everything about it..

Regards


-- 
View this message in context: 
http://old.nabble.com/Unknown-parameter-for-prepare_v2-tp31653746p31653746.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