-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 While i dont know a lot about the DBD::DB2 driver, I would have to say offhand that your call to bind_param shouldnt be referencing your variable
ie.: $sth -> bind_param(1, $var) instead of $sth -> bind_param(1, \$var) and the if test where youre testing $sth[$CUSTNUMBER] against $sth1[$CUSTNUMBER] seems wrong.. i think youll want to test the values in @row and @row1 oh yeah and before you do $dbh -> disconnect, make sure you go: $sth -> finish(); $sth1 -> finish(); On November 12, 2002 19:33 pm, Dana Lucent wrote: > As I sit here contemplating my woes over a fresh Martini, I thought that > I might post my problem in the hopes that those PERL guru's from on high > would bestow a small perl (pun intended) of wisdom upon this poor > individual. > > What is my plight you might ask? I am attempting to read a text file > that contains a single column of data and use those values in an SQL > Select statement. However, as the day wanes, so does my resolve. So, > if you don't mind looking at this snippet of my script, perhaps you > would be so kind as to tell this mere mortal where my problem resides. > (besides the Martini and attitude thank you) > > Automatically creating the file and reading the values stored within is > not an issue. After completing the file and opening the file to > retrieve the values is not an issue. Only when I attempt to "plug" > those values into the SQL statement do I experience head and heart > aches. > > Presented here for the first time, is the aforementioned script: > > my $source = "SFO400P1"; > my $dbh=DBI->connect("dbi:DB2:$source") or die; > # Prepare statement for execution > while(<MPACT>) { > @mpactvals = parse_csv; > $testnum = pop(@mpactvals); > > $sth = $dbh->prepare("SELECT custnumber FROM PCADDTAQUA.party > WHERE custnumber = ?"); > $sth->bind_param(1, \$testnum,{TYPE=>SQL_VARCHAR}); > $dbh->err; > $sth->execute() or die "execute got error"; > $dbh->err; > > $sth1 = $dbh->prepare("SELECT custnumber FROM PCADDTAQUA.party > WHERE custnumber = ?"); > $sth1->bind_param(1, \$testnum, {TYPE=>SQL_VARCHAR}); > $dbh->err; > $sth1->execute() or die "execute got error" . > $dbh->err; > > my @row = $sth->fetchrow_array; > my @row1 = $sth1->fetchrow_array; > > if > ($sth[$CUSTNUMBER] eq $sth1[$CUSTNUMBER]) > print OUTPUTFILE "***SUCCESS! $testnum"; > } > else > { > print OUTPUTFILE "***SUCCESS $testnum"; > } > > } > > ####################### LEAVE THIS SECTION UNCOMMENTED ################ > $stmt = ''; > $stmt1 = ""; > $rc = $dbh->disconnect(); > foreach $key (keys %secs) > { > $stoptime = localtime(time() - $secs{$key}); > } > my $runtime = (($stoptime - $starttime)); > > print OUTPUTFILE "$starttime\n"; > print OUTPUTFILE "$stoptime\n"; > print OUTPUTFILE "$runtime\n"; > > close(MPACT); > close( OUTPUTFILE ); > exit; > > If all code after the statement "$testnum = pop(@mpactvals);" is > commented out (except the print statement "print OUTPUTFILE "***SUCCESS > $testnum"", the output file contains all values to be processed. > However, as it is at this point, I continue to receive a bind_param > error. > > Values to be processed are in the form of 20080, 21907, etc. > > I shall make another Martini and hope that the perl gods shine their > light upon this mere mortal. - -- Michael Wojcikiewicz CodeCrew [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE90aRrzK7WDkEewTARAlLgAJ9GJXTrM9NcqCB2Jar7SrYx0crVRQCfeY1z fPfDuy/RiNk85T0/2g4UrL4= =FZBr -----END PGP SIGNATURE-----