Tie::Function can be used to bind $dbh->quote to a syntactical hash, so you
can interpolate arbitrary strings easier. When I do that I name the hash
%Q, and then it's safe to do things like
$sql_text = "select id from mytable where foo=$Q{$foo}";
rather than counting placeholders.
On Fri, Feb
Short answer, assuming you are including hard-coded SQL into a Perl script:
Place the textual SQL, without any additional backslashes or extra quotes or
whatsoever,
within the following:
my $sql_text = q(
);
Unless you have a closing ")" without a preceding opening "(" in that SQL text
(which w
P.S.
This may also help:
http://www.dispersiondesign.com/articles/perl/perl_escape_characters
Short answer:
Use single-quoted strings whenever possible - they have the fewest characters
to escape - only backslash and single quote - and you can escape both by
preceding with a backslash.
Use d
On Friday 08 February 2019 22:37:17 Mike Martin wrote:
> Has anyone done any work on converting SQL queries between RDBMS and perl?
>
> My particular interest is DBD::Pg but anything would be of use
>
> It would be very useful when I am testing complex SQL, it's very easy to
> miss a \ or quote b
P.P.S.
My last answer used single-quote for a column with a space in it in PostgreSQL
- this is wrong, it should have been a double-quote for the name of the column
with a space and a single quote for a quoted string literal in PostgreSQL.
Better example:
(Adapted from answer to question here
Mike,
If you have a complete example of what you are starting with and what you want
to end up with your question would be clearer.
If I understand you correctly:
You start with raw SQL such as you might enter into a Postgres command line
tool (for example psql).
What you want is the equivalent P
lity ie a 'current_date' function to mimic 'today'
Many here will say start afresh and use an ORM like DBIx::Class or
Fey::ORM<http://search.cpan.org/dist/Fey-ORM> or alike
Cheers
From: Mike Martin
Sent: February 8, 2019 5:37 PM
To: dbi-users@perl.or
Has anyone done any work on converting SQL queries between RDBMS and perl?
My particular interest is DBD::Pg but anything would be of use
It would be very useful when I am testing complex SQL, it's very easy to
miss a \ or quote between the two
Thanks
Mike