Hmmm... I did something bad... I loaded a "|" (pipe) delimted file then did an SQL update using the data from my delimted file. Problem is - it inserted escape characters on each update! This messes up the database. But I am not sure where these escape character come from.
Basically the program switches 1 fields data to the one beside it. Here is part of the file:
ccchg.txt TOADDE|EQANNB| TOADDF|EQANNB| CAABBB|FUAAAF| OFAAAA|OFAA| OFAAAB|OFAA| OFAAAC|OFAA| OFAAAD|OFAA|
Here is the code:
open (CC,"ccchg.txt"); while ($_=<CC>) { push (@CC,$_); ($old,$new)=split(/\|/,$_); push @old,$old; push @new,$new; } close (CC); $i=@old ## get number of codes ### Attributes to pass to DBI->connect() to disable automatic ### error checking my %attr = ( PrintError => 0, RaiseError => 0, ); ### Perform the connection using the Informix driver my $dbh = DBI->connect( "dbi:Informix:nps\@sumitt_dev", "user","password",\%attr ) or die "Can't connect to database: ", $DBI::errstr, "\n"; $sth=$dbh->prepare("SELECT req_id, ccode FROM rtsdet a WHERE req_id IN ('48111','15313','45813','15226','48426','7270 +3') "); $sth->execute(); while ( ($po, $ccode) = $sth->fetchrow_array() ){ push (@po,$po); } $sth->finish; $sth=$dbh->prepare("UPDATE rtsdet SET ccode=? WHERE req_id=? AND ccode +=?"); foreach $po(@po) { for ($count=0; $count<$i;$count++) { $sth->execute($new[$count],$po,$old[$count]); } } $sth->finish; <code> OFAA\ | OFAA\ | OFAA\ | OFAA\ | OFAA\ |
Notice the \ and |. Any idea what is causing these?
apologizes for the bad formatting - trying to delete the spaces deletes all my code when I try - I have to rewrite it all again

Thanks, V
He who laughs last, doesn't get the joke.

2002-03-26 Edit by Corion: Fixed long wrapping line, replaced login information


In reply to VVP:DBI and weird chars by vivekvp

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.