#!perl -w use strict; use DBI; # note: must be uppercase my $dbh = DBI->connect("dbi:ODBC:burlee", "username", "password") or die "Can't connect to database: $DBI::errstr\n"; { # $sth is a static variable for get_sport() # it's private to get_sport(), and keeps its value between calls my $sth; # get_sport($sport, $import) # returns a list of array references sub get_sport { my ($sport, $import) = @_; my $path = "d:/text/time/$sport.txt"; open(TEXT, $path) or die "Can't open $path: $!\n"; my $date = ; chomp $date; close(TEXT); # prepare, if it wasn't prepared before $sth ||= $dbh->prepare(<<" EndOfSQL"); select * from DATA_DB_ENTRY__ASTROS_STAGING where TS_DATE >= ? and IMPORTACE = ? order by TS_DATE asc, TS_TIME asc EndOfSQL $sth->execute($date, $import); my @rows; while (my(@row) = $sth->fetchrow_array()) { push @rows, [@row]; if (@rows == 11) { $sth->finish(); last; } } return @rows; } }