Some of what you're doing makes no sense. You set $ncount to zero, then to a sql statement (and never prepare it, let alone execute it), then you check to see if that statement is greater than '0' (perl has both 'gt' and '>' depending on string or numeric comparison).

Your errcounter and succounter variables are declared at the global level, then you redeclare them in a very limited scope (you need to check out what my really does), and you don't do anything with them in this snippet anyway, so why include in this example?

Instead of asking "Does this work?", it would be better if you actually tried it, see what it does, and then try to fix it. If you are having trouble with any particular part, give some detail about what the problem is with the smallest amount of code possible (and to reduce noise, make up an example with simpler SQL statements, with just a few columns), and we'll still be here :-)

Oh, and welcome to the monestery :-)


In reply to Re: Reading from databse and writing to file. by runrig
in thread Reading from databse and writing to file. by SQLMan

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.