use this querry 'update tablename set fieldname1=newvalue1,fieldname2=newvalue2.... where somefield=something'
----- Original Message ----- From: "Scott Taylor" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 31, 2002 9:34 PM Subject: SQL table updates > Hello all, > > Can anyone tell me how to make this code work, so that, if the record > already exists, just update the values instead of creating a new record? > > open(InFile, "fuelcrd") || die "Can not open file: $!\n"; > while(<InFile>){ > chomp; > my ($FuelCrd, $TrkID, $FuelCmp) = split(/,/,$_); > $FuelCrd =~ s/\"//g; > $TrkID =~ s/\"//g; > $FuelCmp =~ s/\"//g; > chomp($FuelCrd, $TrkID, $FuelCmp); > print "$FuelCrd, $TrkID, $FuelCmp\n"; > $SQL = qq[insert into cardlock (cardno, trkid, fuelcmp) > values ('$FuelCrd', '$TrkID', '$FuelCmp')]; > $sth = $dbh->prepare($SQL) || die "$SQL\n$!\n"; > $sth->execute || die "$SQL\n$!\n"; > } > close InFile; > > $sth->finish; > $dbh->disconnect; > > ---- > > My pseudo code looks like this: > > find first record in table where id = 'blah' > if not available record then create record. > assign values to record. > > Cheers. > > Scott. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]