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]
- Re: SQL table updates Scott Taylor
- Re: SQL table updates Scott Taylor
- Re: SQL table updates LRMK
- RE: SQL table updates Imtiaz ahmad
