+ my $statement;
+ if ( driver_name() eq 'Pg' ) {
+ if (!$dbh) {
+ $dbh = myconnect();
+ $self->{autoclean} = 1;
+ }
+ $self->{dbh} = $dbh;
+ $statement = "DECLARE ".$self->{id}." CURSOR FOR ".$q->{statement};
+ } elsif ( driver_name() eq 'mysql' ) {
+ # build a cursor from scratch
+ #
+ #
+ # there are problems doing it this way, and we don't have time to resolve
+ # them all right now...
+ #$statement = "CREATE TEMPORARY TABLE $self->{id}
+ # (rownum INT AUTO_INCREMENT, PRIMARY KEY (rownum))
+ # $q->{statement}";
+
+ # one of those problems is locking, so keep everything on the main session
+ $self->{dbh} = $dbh = FS::UID::dbh();
+ $statement = $q->{statement};
+ }
+
+ my $sth = $dbh->prepare($statement)
+ or die $dbh->errstr;