Thanks for your input kennethk! First of all 2 & 3 were just basic testing when I first attempted this task and should have removed it when I included here as a question. I agree with 1 and 5, thats where my knowledge lacked, I have since implemented your suggestion. As for 4, I have tried to learn some more about Binding values and been trying for a good chunk of today to get it to work but keep getting different errors: Invalid character value for cast specification & Invalid string or buffer error (see below). I kinds know the former is relating to the date field but haven't figured it out yet, I am lost on the latter.

After looking up Binding values, I understand that its inefficient using interpolating values especially when executing the script multiple times as it doesnt use cached info but besides the inefficiency are there other drawbacks to interpolating? I would prefer to Bind but having spent a significant time troubleshooting the errors I am ready to give in, hence trying to evaluate the risk.

Also, the errors I get do not seem to be caught by the exception handler. Any insight on that?

DBD::ODBC::st execute failed: MicrosoftODBC SQL Server DriverInvalid charact er value for cast specification (SQL-22018) at C:\db_eval_test.pl line 67.

DBD::ODBC::st execute failed: MicrosoftODBC SQL Server DriverInvalid string or buffer length (SQL-HY090) at C:\db_eval_test.pl line 65.

if($DB_insert =~ /true/i) { my $DSN = "driver={SQL Server};server=$server_name;database=$datab +ase_name;uid=$database_user;pwd=$database_pass;"; eval { my $dbh = DBI->connect("dbi:ODBC:$DSN"); DBI->trace(2,'C:\db_test_log.txt'); my $sql = "INSERT INTO RecordCount VALUES (?,?,?,?,?,?)"; my $sth = $dbh->prepare($sql); $sth->bind_param(1, 'test_env'); $sth->bind_param(2, $partner); $sth->bind_param(3, $id); $sth->bind_param(4, $filename); $sth->bind_param(5, "$date $time"); $sth->bind_param(6, $line_count); $sth->execute(); $dbh->disconnect(); }; if($@) { print "DB Failure: $@"; } }

In reply to Re^2: DB Exception Handling by sowais
in thread DB Exception Handling by sowais

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.