perl_gvenk has asked for the wisdom of the Perl Monks concerning the following question:
I have a situation where I'm looping through to generate a SQL statement to update a table. Wha'ts happening though is The site name has an apostrophe in the value and the perl script throws an error at that point.
Here is the piece of code that generates the SQLSQL = UPDATE LIR_BUT_SITE SET ROW_IDENTIFIER = '4' , M_CUSTOMER_ABBREV = 'IBHW' , M_SITE_KEY = 'R_LIR_BUT_SITE-' , RESP_CENTER = 'Global Custom Svcs GCSC' , M_SITE_NAME = 'MZ3481-CHILDREN'S HOSPITAL WALTHAM'
for $idx (0..$#hdr) { if ($row[$idx] ne "") { if ($found ne "N") { $updstmt .= ", "; $insstmt .= ", "; $valstmt .= ", "; } $found = "Y"; $updstmt .= $hdr[$idx]." = '".$row[$idx]."' \ +r\n";
The values for the update are generated by the $row$idx.How do I put that $row$idx within double quotes or how do i make the perl interpreter escape any apostrophes in that field. Can some one suggest a solution?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Escaping Apostrophe
by haukex (Archbishop) on Oct 20, 2017 at 13:49 UTC | |
by perl_gvenk (Initiate) on Oct 20, 2017 at 14:02 UTC | |
by AnomalousMonk (Archbishop) on Oct 20, 2017 at 16:08 UTC | |
|
Re: Escaping Apostrophe
by Your Mother (Archbishop) on Oct 20, 2017 at 15:35 UTC | |
by LanX (Saint) on Oct 20, 2017 at 16:55 UTC | |
|
Re: Escaping Apostrophe
by LanX (Saint) on Oct 20, 2017 at 14:31 UTC | |
|
Re: Escaping Apostrophe
by Your Mother (Archbishop) on Oct 21, 2017 at 02:59 UTC |