# Our program for today...

## #!/usr/bin/perl -w

## use DBI;

## $dbh = DBI->connect('', '', '', { RaiseError => 1 });

## replace_price(split(/\s+/, $_)) while (<STDIN>);

## $dbh->disconnect;

##

## sub replace_price {

## my ($id, $price) = @_;

## local $dbh->{TraceLevel} = 1;

## my $upd = $dbh->prepare("UPDATE prices SET price=? WHERE id=?");

## my $ins = $dbh->prepare_cached("INSERT INTO prices (id,price) VALUES(?,?)");

## my $rows = $upd->execute($price, $id);

## $ins->execute($id, $price) if $rows == 0;

## }

(The program is a little odd for the sake of producing a small trace output that can illustrate many concepts)

Previous slide | Next slide | Back to first slide | View graphic version