Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: Re: Exists

by SamueD2 (Novice)
on Apr 14, 2003 at 17:27 UTC ( [id://250347] : note . print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Exists
in thread Update/insert record in database

Below is the script that I have. I like the idea of using a stored procedure. But I dont know how to bind my scalar to a param and how do I call the stored procedure. The database i am using is MS SQL SERVER. Thanks for your help
use strict; use warnings; use DBI; #use Win32::ODBC; use DBD::ODBC; if (-e "v:/tf_out.txt") { } else { die "File does not exist\n"; } #my $filename = shift || die "Please provide a filename.\n"; #my $Data = new Win32::ODBC("DSN=INSTDev;UID=sa;PWD=;"); #my $dbh = new Win32::ODBC("DSN=INSTDev;UID=sa;PWD=;")or die "Unable t +o connect: "; my $dbh = DBI->connect( "dbi:ODBC:RETDEV_SQL", "sa", "", {RaiseError => 1, PrintError => 1, AutoCommit => 0} ) or die "Unable to connect: ";#. $DBI::errstr . "\n"; # Open your file open( INFILE, "v:/tf_out.txt" ) or die "Couldn't open file for reading +.$!\n"; while( $line = <INFILE> ) { my @data = split( "\t", $line ); $CLIENT = $data[0]; $RECORD = $data[1]; $CONTROL = $data[2]; $CUSIP = $data[3]; $FROMACCT = $data[4]; $F_IND = $data[5]; $TOACCT = $data[6]; $T_IND = $data[7]; $FP = $data[8]; $ORIGQTY = $data[9]; $DIV = $data[10]; $LTCG = $data[11]; $STCG = $data[12]; $SOCSEC = $data[13]; $BKRNO = $data[14]; $THIRDPARTYCD = $data[15]; $USERID = $data[16]; $EDATE = $data[17]; $ORIGAMT = $data[18]; $CLOSEDIND = $data[19]; $ADPSECNO = $data[20]; $BRNCH = $data[21]; $ACNT = $data[22]; $TYPE = $data[23]; $CHKDIGIT = $data[24]; $PDATE = $data[25]; $ACTLQTY = $data[26]; $ACTLAMT = $data[27]; $CERTIND = $data[28]; $REQST = $data[29]; $RDATE = $data[30]; $COMNTS = $data[31]; $COMNTS=~s/\'/''/g; $TRNFTYPE = $data[32]; $FILLER1 = $data[33]; $ADR_L1 = $data[34]; $ADR_L1=~s/\'/''/g; $ADR_L2 = $data[35]; $ADR_L2=~s/\'/''/g; $ADR_L3 = $data[36]; $ADR_L3=~s/\'/''/g; $ADR_L4 = $data[37]; $ADR_L4=~s/\'/''/g; $ADR_L5 = $data[38]; $ADR_L5=~s/\'/''/g; $ADR_L6 = $data[39]; $ADR_L6=~s/\'/''/g; $FILLER_B = $data[40]; $CERTNO1 = $data[41]; $CERTSHRS1 = $data[42]; $CERTNO2 = $data[43]; $CERTSHRS2 = $data[44]; $CERTNO3 = $data[45]; $CERTSHRS3 = $data[46]; $CERTNO4 = $data[47]; $CERTSHRS4 = $data[48]; $CERTNO5 = $data[49]; $CERTSHRS5 = $data[50]; $CERTNO6 = $data[51]; $CERTSHRS6 = $data[52]; $CERTNO7 = $data[53]; $CERTSHRS7 = $data[54]; $CERTNO8 = $data[55]; $CERTSHRS8 = $data[56]; $CERTNO9 = $data[57]; $CERTSHRS9 = $data[58]; $CERTNO10 = $data[59]; $CERTSHRS10 = $data[60]; $FILLER_G = $data[61]; #print "@cols"; #print "$CLIENT"; $sth->bind_param(1,$CLIENT); $sth->bind_param(2,$RECORD); $sth->bind_param(3,$CONTROL); $sth->bind_param(4,$CUSIP); $sth->bind_param(5,$FROMACCT); $sth->bind_param(6,$F_IND); $sth->bind_param(7,$TOACCT); $sth->bind_param(8,$T_IND); $sth->bind_param(9,$FP); $sth->bind_param(10,$ORIGQTY); $sth->bind_param(11,$DIV); $sth->bind_param(12,$LTCG); $sth->bind_param(13,$STCG); $sth->bind_param(14,$SOCSEC); $sth->bind_param(15,$BKRNO); $sth->bind_param(16,$THIRDPARTYCD); $sth->bind_param(17,$USERID); $sth->bind_param(18,$EDATE); $sth->bind_param(19,$ORIGAMT); $sth->bind_param(20,$CLOSEDIND); $sth->bind_param(21,$ADPSECNO); $sth->bind_param(22,$BRNCH); $sth->bind_param(23,$ACNT); $sth->bind_param(24,$TYPE); $sth->bind_param(25,$CHKDIGIT); $sth->bind_param(26,$PDATE); $sth->bind_param(27,$ACTLQTY); $sth->bind_param(28,$ACTLAMT); $sth->bind_param(29,$CERTIND); $sth->bind_param(30,$REQST); $sth->bind_param(31,$RDATE); $sth->bind_param(32,$COMNTS); $sth->bind_param(33,$TRNFTYPE); $sth->bind_param(34,$FILLER1); $sth->bind_param(35,$ADR_L1); $sth->bind_param(36,$ADR_L2); $sth->bind_param(37,$ADR_L3); $sth->bind_param(38,$ADR_L4); $sth->bind_param(39,$ADR_L5); $sth->bind_param(40,$ADR_L6); $sth->bind_param(41,$FILLER_B); $sth->bind_param(42,$CERTNO1); $sth->bind_param(43,$CERTSHRS1); $sth->bind_param(44,$CERTNO2); $sth->bind_param(45,$CERTSHRS2); $sth->bind_param(46,$CERTNO3); $sth->bind_param(47,$CERTSHRS3); $sth->bind_param(48,$CERTNO4); $sth->bind_param(49$CERTSHRS4); $sth->bind_param(50,$CERTNO5 ); $sth->bind_param(51,$CERTSHRS5); $sth->bind_param(52,$CERTNO6 ); $sth->bind_param(53,$CERTSHRS6); $sth->bind_param(54,$CERTNO7 ); $sth->bind_param(55,$CERTSHRS7 ); $sth->bind_param(56,$CERTNO8 ); $sth->bind_param(57,$CERTSHRS8); $sth->bind_param(58,$CERTNO9 ); $sth->bind_param(59,$CERTSHRS9 ); $sth->bind_param(60,$CERTNO10 ); $sth->bind_param(61,$CERTSHRS10); $sth->bind_param(62,$FILLER_G ); $sth

Edit by tye, add CODE and READMORE tags (code was truncated when I got here).