I still use bind variables in combination with TT, but I'm able to do "more than I could with just bind variables." For example, query.sql might contain:
Of course, you could also do the above with sprintf, but splitting it into a separate file with TT I'm not mixing SQL and Perl. I can open my SQL up in an editor and get syntax highlighting for SQL.
I can use TT to include SQL snippets in a larger query instead of copy and pasting the same snippet over and over. In my context of higher ed, I need to limit many of the queries I run to the current term. I can throw SQL querying the term table for terms where the start date is less than sysdate and the end date is greater than sysdate into a file and then include it in other queries with where term in ([% INCLUDE active-terms.sql %]).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I still use bind variables in combination with TT, but I'm able to do "more than I could with just bind variables." For example,
query.sql
might contain:and this is how I would process it with Perl (using Template::Toolkit::Simple):
Of course, you could also do the above with
sprintf
, but splitting it into a separate file with TT I'm not mixing SQL and Perl. I can open my SQL up in an editor and get syntax highlighting for SQL.I can use TT to include SQL snippets in a larger query instead of copy and pasting the same snippet over and over. In my context of higher ed, I need to limit many of the queries I run to the current term. I can throw SQL querying the term table for terms where the start date is less than
sysdate
and the end date is greater thansysdate
into a file and then include it in other queries withwhere term in ([% INCLUDE active-terms.sql %])
.