#!/usr/bin/perl ## include the necessary module ## use DBI; ## connect to the oracle database ## $dbh = DBI->connect("dbi:Oracle:", 'username/password'); ## prepare the sql statement - note the use of multi-line quotation ## $cursor = $dbh->prepare(qq| SELECT title, quality, TO_CHAR(airdate, 'mm-dd-yyyy') FROM episodes WHERE season = 2 AND quality=7 |); ## execute the statement ## $cursor->execute(); ## a while loop that fetches each row returned by the SQL statement ## ## where there are no more values returned it will break out of the loop ## ## also note the second form of multi-line strings ## while (my ($title, $quality, $airdate) = $cursor->fetchrow()) { print <finish; ## update the database ## $rowsChanged = $dbh->do(qq| UPDATE episodes SET quality = 8 WHERE title='The Dauphin' |); ## if more than one row was changed, it succeeded, else failure ## print (($rowsChanged > 0) ? "Update Succeeded!\n" : "Update Failed!\n"); $dbh->disconnect; exit();