lortherin schrieb am 28.05.2012 um 20:07 (-0000):

> -- ISQL scriptlet:

> -- Two triggers to go with it:
> set term ;!!

At this point, it should be:

  set term !! ;

> And a perl script which will show the error.  I know this is probably
> horrible perl-fu.

Looks good to me. But I couldn't get it to work on Windows and using
DBD::Firebird. (DBD::InterBase didn't even compile, and it seems to
have been superseded by DBD::Firebird.) I got all sorts of strange
error, not reliably reproducible. Looked like concurrency issues to
me, but then I don't know much about them.

The synchronous method (ib_wait_event instead of ib_register_callback
and ib_cancel_callback) worked fine, though:


use strict;
use warnings;
use DBI;
use POSIX qw(strftime mktime);
use Time::HiRes 'time';

my $db   = shift or die 'database!';
my $user = shift or die 'username!';
my $pass = shift or die 'password!';

my $dbi = DBI->connect('dbi:Firebird:' . $db, $user, $pass,
    { PrintError => 0, RaiseError => 1, AutoCommit => 1 });

my $station = 1;
my $curr_date = mktime(0, 0, 0, 1, 0, 110);  # 01 Jan 2010 @00:00
my $end_date = mktime(0, 0, 0, 1, 0, 111);   # 01 Jan 2011 @00:00

my $insert_count = 0;
my $t0 = time;

my $sql = "execute procedure insert_log_entry (?, ?, ?, ?, ?, ?)";
my $sth = $dbi->prepare($sql);

while ($curr_date < $end_date) {
    my @lt_curr_date = localtime $curr_date;
    my $dd = strftime '%Y-%m-%d', @lt_curr_date;
    my $hh = sprintf '%.2d', $lt_curr_date[2]; # hour
    my $tt = "${hh}:000:00.00";

    my $ev1 = "PLAYLIST_INSERTED_${station}_${dd}_${hh}";
    my $ev2 =  "PLAYLIST_DELETED_${station}_${dd}_${hh}";
    my $evh = $dbi->func($ev1, $ev2, 'ib_init_event');

    my $res = $sth->execute($station, $dd, $tt, 'Event Test Entry', 0, 'N');
    $sth->finish; # call needed to trigger event!
    $insert_count++;
    printf "%5u - Inserted $dd $hh\n", $insert_count;

    my $events = $dbi->func($evh, 'ib_wait_event');
    if ( $events ) {
        while ( my($evnam, $evcount) = each %$events ) {
            printf "%50s %2u\n", $evnam, $evcount;
        }
    }

    $curr_date += 3600; # Bump to next hour and repeat
}

$dbi->disconnect;
printf "inserted $insert_count records in %.2f seconds\n", time - $t0;
__END__


Note that I didn't get any Firebird server errors as I tested against
the latest 2.5.1 (Win32 build on Win7/64).
-- 
Michael Ludwig

Reply via email to