• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

SQL placeholders

AtW

I post more often than I breathe
Thanks received
1,318
Are way too limited!

Why can't I do this (bold are bits used for placing params):

select * from TableName_@param1 where Domain='@param2'

:tantrum:
 
Now you are just being silly.

SQL has an ANSI std and that is not in it.

You can do it using proprietary extensions that allow dynamic SQL execution and other well know means.

Watch out for SQL injection flaws when using dynamic SQL.
 
This functionality is not exposed to anything that can inject that kind of stuff, @param1 is integer anyway.

Seems like I will have to manually interpolate @param1 here and then prepare statement using placeholder in place of @param2 - SQLite shown to use a LOT of CPU preparing statements all the time because they used crappy slow .NET's regular expressions. :tantrum:
 
I am still on Finisar, but I believe placeholders wise it is fundamendal issue that they can't have the kind of stuff above - they want to compile statement fully, so table name should be known in advance, will have to change it the same way I do now for each query, but then prepare it (once table name is known during batch inserts) and use that prepared statement.

Also ?nnn placeholders don't seem to work in it :bang:
 
AtW said:
I am still on Finisar, but I believe placeholders wise it is fundamendal issue that they can't have the kind of stuff above - they want to compile statement fully, so table name should be known in advance, will have to change it the same way I do now for each query, but then prepare it (once table name is known during batch inserts) and use that prepared statement.

Also ?nnn placeholders don't seem to work in it :bang:

Haven't you just answered your own question of why?
 
DimPrawn said:
Haven't you just answered your own question of why?

They could have made it more powerful while still providing benefits of parsing query only once, just leave table name resolves and stuff like that until the last moment.
 

Advertisers

Back
Top