Seeking the wisdom of the Perl Monks in the updation of records using Win32::ODBC (database used - Oracle)
I have the following code:
$dsn=$config->{'DSN'}; $db = new Win32::ODBC("$dsn"); if (!$db) { print "Cannot connect to DSN $dsn\n"; return 0; } #@updatequeryarray is the array containing the Update statements #for eg.: UPDATE EMPLOYEE SET REMARKS='Test now for Ryan' WHERE EM +P_NO='295' AND EMP_JOIN_YEAR='200102' foreach my $query (@updatequeryarray) { $dbgstr.="\n $query"; $db->Sql($query); } $db->Close();

Here I have inserted the Update statements into the @updatequeryarray! But on execution the update statement works only the first time in the loop. I don't understand why the update statements does not work when executed thru a loop!!!

So to bypass the problem and to set the things working for the time being, I have changed the code so that each time the for loop is executed, a connection to the database is made and after updation of the single record the connection is closed.

I seek the wisdom of the Perl Monks in this!!!!

Thanks in advance

George


In reply to Win32::ODBC - Update SQL statement by Anonymous Monk

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.