PerlAcolyte has asked for the wisdom of the Perl Monks concerning the following question:
code for stored procuse DBI; my $dbh = DBI->connect( "$dbServer", "$dbUser", "$dbPass" ) or print " +Could not make connection to database"; open(DAILY, "$updateDir/$fileName") || print "CAN'T OPEN DAILY"; while(<DAILY>){ chomp; my ($field1,$field2,$field3,$field3,$field4,$field5,$field6,$field +7,$field8) = split(/,/); if ($field1 == 33){ my $spQuery = "exec my_sp ?,?,?,?,?,?,?"; $insert33 = $dbh->prepare( $spQuery ) or die ( "Cannot + prepare statement: ", $dbh->errstr(), "\n" ); $insert33->execute($field1,$field2,$field3,$field4,$fi +eld5,$field6,$field7) or die( "Cannot execute statement: ", $insert33->errst +r(), "\n" ); $insert33->finish(); } } close(DAILY);
@field1 AS INTEGER, @field2 AS DATETIME, @field3 AS MONEY, @field4 AS MONEY, @field5 AS MONEY, @field6 AS MONEY, @field7 AS INTEGER AS BEGIN DECLARE @check1 INT SET @check1 = 0 SELECT @check1 = col1 FROM tableX WHERE col3 = @field1 IF @check1 > 0 BEGIN INSERT INTO priceHistory (col1,col2,col3,col4,col5,col6,col7) VALUES (@field1,@field2,@field3,@field4,@field5,@field6,@field7) END END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI Inserting Duplicate Records
by graff (Chancellor) on Dec 30, 2007 at 00:38 UTC | |
|
Re: DBI Inserting Duplicate Records
by bradcathey (Prior) on Dec 29, 2007 at 18:18 UTC | |
by PerlAcolyte (Initiate) on Dec 29, 2007 at 19:16 UTC | |
|
Re: DBI Inserting Duplicate Records
by almut (Canon) on Dec 30, 2007 at 00:25 UTC |