Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread John Machin
On 20/06/2009 12:06 AM, Shaun Seckman (Firaxis) wrote:
> Not sure I fully understand what you mean.

> Is it not possible to replace the table name in the prepared statement?

It is not possible.

>  What sort of things can I replace then?

You can do replacement at any place where a "literal" (i.e. a constant) 
is legal.

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


Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Shaun Seckman (Firaxis)
Ah, that makes more sense :)  Thanks a bunch for the clarification!

-Shaun

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Pavel Ivanov
Sent: Friday, June 19, 2009 10:57 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Literal replacements in prepared statements

Yes, it's impossible to replace table or column names. You can replace
any constant values like this:

select table.column2, column3 + ?
from table
where column1 = ? and column2 + ? > column3
limit ?, ?

Pavel

On Fri, Jun 19, 2009 at 10:06 AM, Shaun Seckman
(Firaxis) wrote:
> Not sure I fully understand what you mean.  Is it not possible to replace the 
> table name in the prepared statement?  What sort of things can I replace then?
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov
> Sent: Friday, June 19, 2009 10:03 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Literal replacements in prepared statements
>
> You're trying identifier replacement, not literal replacement. It's
> not allowed. You have to write table name without binding.
>
> Pavel
>
> On Fri, Jun 19, 2009 at 9:58 AM, Shaun Seckman
> (Firaxis) wrote:
>> I'm trying to add some literal replacements in my prepared SQL statement
>> but I'm currently getting a SQL syntax error.
>>
>> Here's a snippit of what I'm trying to do:
>>
>>
>>
>> ...
>>
>> sqlite3_stmt* stmt;
>>
>> sqlite3_prepare_v2(db, "Select * from ?", -1, &stmt, NULL);   <-- near
>> "?": syntax error
>>
>> sqlite3_bind_text(stmt, 1, tableName, -1, SQLITE_TRANSIENT);
>>
>> ...
>>
>>
>>
>> Any idea what I'm doing wrong?
>>
>>
>>
>> -Shaun
>>
>>
>>
>>
>>
>>
>>
>> ___
>> 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
> ___
> 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
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Pavel Ivanov
Yes, it's impossible to replace table or column names. You can replace
any constant values like this:

select table.column2, column3 + ?
from table
where column1 = ? and column2 + ? > column3
limit ?, ?

Pavel

On Fri, Jun 19, 2009 at 10:06 AM, Shaun Seckman
(Firaxis) wrote:
> Not sure I fully understand what you mean.  Is it not possible to replace the 
> table name in the prepared statement?  What sort of things can I replace then?
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov
> Sent: Friday, June 19, 2009 10:03 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Literal replacements in prepared statements
>
> You're trying identifier replacement, not literal replacement. It's
> not allowed. You have to write table name without binding.
>
> Pavel
>
> On Fri, Jun 19, 2009 at 9:58 AM, Shaun Seckman
> (Firaxis) wrote:
>> I'm trying to add some literal replacements in my prepared SQL statement
>> but I'm currently getting a SQL syntax error.
>>
>> Here's a snippit of what I'm trying to do:
>>
>>
>>
>> ...
>>
>> sqlite3_stmt* stmt;
>>
>> sqlite3_prepare_v2(db, "Select * from ?", -1, &stmt, NULL);   <-- near
>> "?": syntax error
>>
>> sqlite3_bind_text(stmt, 1, tableName, -1, SQLITE_TRANSIENT);
>>
>> ...
>>
>>
>>
>> Any idea what I'm doing wrong?
>>
>>
>>
>> -Shaun
>>
>>
>>
>>
>>
>>
>>
>> ___
>> 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
> ___
> 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


Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Shaun Seckman (Firaxis)
Not sure I fully understand what you mean.  Is it not possible to replace the 
table name in the prepared statement?  What sort of things can I replace then?

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Pavel Ivanov
Sent: Friday, June 19, 2009 10:03 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Literal replacements in prepared statements

You're trying identifier replacement, not literal replacement. It's
not allowed. You have to write table name without binding.

Pavel

On Fri, Jun 19, 2009 at 9:58 AM, Shaun Seckman
(Firaxis) wrote:
> I'm trying to add some literal replacements in my prepared SQL statement
> but I'm currently getting a SQL syntax error.
>
> Here's a snippit of what I'm trying to do:
>
>
>
> ...
>
> sqlite3_stmt* stmt;
>
> sqlite3_prepare_v2(db, "Select * from ?", -1, &stmt, NULL);   <-- near
> "?": syntax error
>
> sqlite3_bind_text(stmt, 1, tableName, -1, SQLITE_TRANSIENT);
>
> ...
>
>
>
> Any idea what I'm doing wrong?
>
>
>
> -Shaun
>
>
>
>
>
>
>
> ___
> 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
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Literal replacements in prepared statements

2009-06-19 Thread Pavel Ivanov
You're trying identifier replacement, not literal replacement. It's
not allowed. You have to write table name without binding.

Pavel

On Fri, Jun 19, 2009 at 9:58 AM, Shaun Seckman
(Firaxis) wrote:
> I'm trying to add some literal replacements in my prepared SQL statement
> but I'm currently getting a SQL syntax error.
>
> Here's a snippit of what I'm trying to do:
>
>
>
> ...
>
> sqlite3_stmt* stmt;
>
> sqlite3_prepare_v2(db, "Select * from ?", -1, &stmt, NULL);   <-- near
> "?": syntax error
>
> sqlite3_bind_text(stmt, 1, tableName, -1, SQLITE_TRANSIENT);
>
> ...
>
>
>
> Any idea what I'm doing wrong?
>
>
>
> -Shaun
>
>
>
>
>
>
>
> ___
> 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


[sqlite] Literal replacements in prepared statements

2009-06-19 Thread Shaun Seckman (Firaxis)
I'm trying to add some literal replacements in my prepared SQL statement
but I'm currently getting a SQL syntax error.

Here's a snippit of what I'm trying to do:

 

... 

sqlite3_stmt* stmt; 

sqlite3_prepare_v2(db, "Select * from ?", -1, &stmt, NULL);   <-- near
"?": syntax error

sqlite3_bind_text(stmt, 1, tableName, -1, SQLITE_TRANSIENT);

...

 

Any idea what I'm doing wrong?

 

-Shaun

 

 

 

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