If "$hist_plan_prolog_1" is a table name, and NOT a perl variable, the best bet is to use non-interpolating single quotes, and NOT escape the $.

But the query would be more readable if you used "heredoc" syntax.

here is a sample I use:

my $sql=<<"_SQL_"; SELECT cl_plugins.pid_number as pid, plugin_catalog.pid AS plugin_ +name, plugin_catalog.description AS name, plugin_catalog.version, bui +ld FROM cl_plugins, plugin_catalog WHERE cl_plugins.cid::text = '$proxy->{CID}' AND cl_plugins.pid_number = plugin_catalog.pid_number AND cl_plugins.version::text = plugin_catalog.version::text; _SQL_
In my case, I DO use interpolation, and the string does expand the reference to $proxy->{CID}.

Your query could be:

my $sql=<<"__SQL__"; SELECT to_char(pp.SUBMITTIME, 'YYYY-MM-DD HH:MM:SS') SUBMITTIME, to_char(pp.QUEUETIME, 'YYYY-MM-DD HH:MM:SS') QUEUETIME, to_char(pp.PREPTIME, 'YYYY-MM-DD HH:MM:SS') PREPTIME, to_char(pp.STARTTIME, 'YYYY-MM-DD HH:MM:SS') STARTTIME, pp.SESSIONID, pp.PLANID from '\$hist_plan_prolog_1' pp where pp.SUBMITTIME between '2014-06-26 05:00' and '2014-06-26 08:00:0 +0' order by pp.SUBMITTIME __SQL__
This allows for the potential introduction of perl variables, where you would NOT escape the $.

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992


In reply to Re: Escaping and quoting ????? by NetWallah
in thread Escaping and quoting ????? by pgduke65

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.