pragov has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I use this in CGI

$PTName =~ s/,/','/g; if ($PTName) { $Where = $Where . "AND E.PT_name IN ANY ($PTName) "; }

to select multi names pairs from a list box

isc01cfa,isc02cfa isc03ifa,isc04ifa

But the teradata SQL output it gives

..........AND E.PT_name IN ANY ('isc01cfa','isc02cfa'',''isc03ifa','is +c04ifa')
It puts the two single quotes after the pair and before next pair. I need it to be as AND E.PT_name IN ANY ('isc01cfa','isc02cfa','isc03ifa','isc04ifa') How to modify the CGI?

Thanks, Pragov

Replies are listed 'Best First'.
Re: eliminating double quote
by stevieb (Canon) on Nov 25, 2014 at 20:09 UTC

    Please use code tags to surround code and data.

    Do the double quotes appear as a return within the code or direct SQL return or both? It's a bit difficult to tell with your question.

    -stevieb

      Hi All, I use this in CGI

      </code> $PTName =~ s/,/','/g; if ($PTName) { $Where = $Where . "AND E.PT_name IN ANY ($PTName) "; } </code>

      to select multi names pairs from a list box isc01cfa,isc02cfa isc03ifa,isc04ifa But the teradata SQL output it gives ..........AND E.PT_name IN ANY ('isc01cfa','isc02cfa'',''isc03ifa','isc04ifa') It puts the double quote after the pair and before next pair.

      How to modify the CGI? Thanks, Pragov

        I'm guessing your double quotes are 2 single quotes, in which case this might work
        #!perl use strict; my $PTName = "'isc01cfa,isc02cfa','isc03ifa,isc04ifa'"; $PTName =~ s/','/,/g; # add $PTName =~ s/,/','/g; print $PTName;
        poj
        Your code tag is still wrong, because you have a / in the opening tag, which should be <code> and not </code> as you currently have it. Changing it should make your code formatting clearer.

        And please, maybe you could rephrase the question, for the time being, I fail to understand the real nature of your problem.

Re: eliminating double quote
by chacham (Prior) on Nov 26, 2014 at 13:32 UTC

    Side comments. It's best not to use dynamic SQL. ANY is an optional keyword which most people leave out (and thus might cause confusion if left in.) If the list were static, the clause could be: AND E.PT_name LIKE 'isc0__fa'. Without context it is hard to tell if something similar would apply in your case.

Re: eliminating double quote
by Laurent_R (Canon) on Nov 26, 2014 at 08:38 UTC
    Still wrong formatting. The opening code tag should be <code> and the closing code tag should be </code>