All I'm having a problem with my while loop. It reads the data out of the file and displays the first record of the array for until the end-of-file.
However, I cannot get it to insert this value into the table. Any guidence would be helpful. Thanks, Bobby

#!/usr/bin/perl # #Connects to a Sybase Database use DBI; #Loads DBI module #Connect using ARSAMSDBA.... my $dbh = DBI->connect("dbi:ODBC:usamma", "arsamsdba", "arsamssql", { PrintError => 0, RaiseError => 0 }) or die "Can't connect to database: $DBI::errstr\n"; #Prepare Create Parser Table statement.... my $sth = $dbh->prepare("CREATE TABLE PARSER_TABLE ( NIIN char(9) NOT NULL, FSC char(4) NOT NULL, PRIME_NSN varchar(16) NULL, MATCAT char(5) NULL, SOS char(3) NULL, DML char(1) NULL, EC char(1) NULL, RICC char(1) NULL, ARC char(1) NULL, SCIC char(1) NULL, AAC char(1) NULL, LCC char(1) NULL, PHC varchar(1) NULL, RC char(1) NULL, SCMC char(2) NULL, AMDF_PRICE varchar(20) NULL, CRED_SERV varchar(20) NULL, CRED_UNSERV varchar(20) NULL, UI char(2) NULL, UM char(2) NULL, MEAS_QTY varchar(20) NULL, ARI char(1) NULL, MR char(1) NULL, Nomen char(21) NULL, EIC char(3) NULL, CIIC char(1) NULL, LIN char(6) NULL, smr_cd varchar(5) NULL, WRTY char(1) NULL, WSC char(3) NULL, model varchar(50) NULL, Notes varchar(128) NULL, DEMIL char(1) NULL )" ) or die "Can't prepare SQL statement: $DBI::errstr\n"; #Excute Create Table statement.... $sth->execute or die "Can't execute SQL statment: $DBI::errstr\n"; #Disconnect ARSAMSDBA..... $dbh->disconnect or warn "Disconnection failed: $DBI::errstr\n"; #Connect using DBA (Opens DB Handle).... $dbh = DBI->connect("dbi:ODBC:usamma", "dba", "sql", { PrintError => 0, RaiseError => 0 }) or die "Can't connect to database: $DBI::errstr\n"; #Execute to delete records from arsamsdba.parser_table.... my $sth0 = $dbh->do("DELETE arsamsdba.PARSER_TABLE") or die "Can't pre +pare SQL statement: $DBI::errstr\n"; #Prepare for input into arsamsdba.parser_table.... my $sth1 = $dbh->prepare("INSERT INTO ARSAMSDBA.PARSER_TABLE (NIIN) VA +LUES (?)"); my $sth2 = $dbh->prepare("commit"); open AFH, "D:/WorkingFiles/Scripts/perl/amdfdata.txt" or die "Can't op +en D:/WorkingFiles/Scripts/perl/amdfdata.txt: $!\n"; while(!eof AFH) { my $line = <AFH>; #take in new line chomp; #trim leading (and trailing) quotes $line =~ s/^\"//; @row=split(/\"[^\"]\"\,{0,1}/,$line); print "$row[0]\n"; $sth1->bind_param(1, $niin); $sth1->execute($row[0]); } $sth2->execute(); close AFH or warn "Can't close D:/WorkingFiles/Scripts/perl/amdfdata.t +xt: $!\n"; $dbh->disconnect or warn "Disconnection failed: $DBI::errstr\n"; exit; #, FSC, PRIME_NSN, MATCAT, SOS, DML, EC, RICC, ARC, SCIC, AAC, LCC,PHC +, RC, SCMC, AMDF_PRICE, CRED_SERV, CRED_UNSERV, UI, UM, MEAS_QTY, AR +I, MR, #NOMEN, EIC, CIIC, #LIN, DEMIL) # VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? +,?,?,?,?)"); #$niin, $fsc, $prime_nsn, $matcat, $sos, $dml, $ec, $ricc, $arc, $scic +, $aac, $lcc, $phc, $rc, $scmc, $amdf_price, $cred_serv, #$cred_unserv, $ui, $um, $meas_qty, #$ari, $mr, $nomen, $eic, $ciic, $ +lin, $demil);

In reply to Insert into database table by curtisb

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.