in reply to Perl DBI '?' substitution with prepare/execute
As a rule of thumb, you can only use SQL placeholders when the database can still come up with a query plan. Using a different table prevenets your database from coming up with a sensible query plan.
A more concise way to say this is that the placeholders can only stand in place for values, not for arbitrary syntax constructs.
You will have to construct the SQL by creating a string and replacing the variable parts in the string yourself.
There are some query builders, like SQL::Abstract, or DBIx::PreQL. In my experience, I found query builders to be too tedious, as I usually have to fight them too hard to get the SQL I want them to generate. I haven't used DBIx::PreQL, but it should allow you a more parametrized approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl DBI '?' substitution with prepare/execute (abstract SQL)
by LanX (Saint) on Apr 18, 2016 at 16:06 UTC | |
by SimonPratt (Friar) on Apr 18, 2016 at 16:25 UTC | |
by LanX (Saint) on Apr 18, 2016 at 16:35 UTC | |
by SimonPratt (Friar) on Apr 19, 2016 at 08:17 UTC |