<%init> use AwayMsg; db_connect(); <%args> $textid $save => 0 $cancel => 0 $textid => undef <%perl> if ($save) { my $ins; $dbh->do('BEGIN'); if ($textid eq 'new') { my $ntextq = $dbh->prepare("SELECT textid FROM texts". " ORDER BY textid DESC LIMIT 1"); $ntextq->execute(); my $ntextrow = $ntextq->fetchrow_hashref(); if ($ntextrow) { $textid = $ntextrow->{'textid'} + 1; } else { $textid = 1; } } else { my $dtextq = $dbh->prepare("DELETE FROM texts WHERE textid = ?"); my $ndeleted = $dtextq->execute($textid); if (!$ndeleted) { $ins = $dbh->prepare("INSERT INTO texts VALUES ( $sth = $dbh-> }