dbi

Perl simulating Net::DBI fetchall_arrayref()

I have to simulate an array as if it was returned from Net::DBI fetchall_arrayref function. Lets say that the SQL query is something like "SELECT data1,data2,data3 from table1 " I have an XML file as <type1> <data1>a</data1> <data2>b</data2> <data3>c</data3> </type1> <type1> <data1>da</data1> <data2>db</data2> <data3>dc<...

How can I get DBD::Pg to time out reliably?

Why doesn't this code execute the signal handler until after $sth->execute completes? And more importantly, how can I fix it? #!/usr/bin/perl use strict; use warnings; use DBI; use Sys::SigAction qw( set_sig_handler ); my $dbh = DBI->connect('dbi:Pg:dbname=dc'); eval { my $h = set_sig_handler('ALRM', sub { die "timeout\n" }); ...

Why does SQLite give a "database is locked" for a second query in a transaction when using Perl's DBD::SQLite?

Is there a known problem with SQLite giving a "database is locked" error for a second query in a single transaction when using Perl DBD::SQLite? Scenario: Linux, Perl DBI, AutoCommit => 0, a subroutine with two code blocks (using the blocks to localize variable names). In the first code block a query handle is created by prepare() on a s...

DBI database handle with AutoCommit set to 0 not returning proper data with SELECT?

This is a tricky one to explain (and very weird), so bear with me. I will explain the problem, and the fix for it, but I would like to see if anyone can explain why it works the way it works :) I have a web application that uses mod_perl. It uses MySQL database, and I am writing data to a database on regular basis. It is modular, so it ...

syb_nsql vs execute calls in Perl

I am trying to query Sybase database using DBD::Sybase. Can someone please clarify what is the difference between using syb_nsql vs prepare(...) - execute(..) calls? ...

How can I check that LOADing data into my database succeeded?

I need to ensure that this LOAD query succeeded. How do I know inside my program it did not fail? sub loaddata{ my ($name) = @_; my $DBH = init_dbh( ); my $STH_GO = $DBH->prepare(q{ LOAD DATA LOCAL INFILE '?' INTO TABLE authors FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r...

ct_results() and ct_cmd_drop() error with Sybase::CTlib

I'm using Sybase::CTlib to query a Sybase server. However when I execute the following: while( $dbr->ct_results($restype) == CS_SUCCEED ) { if( $restype == CS_CMD_FAIL ) { warn "Update Check Failed..."; next; } next unless $dbr->ct_fetchable($restype); $ts = $dbr->ct_fetch; } My query returns exactly one value....

Async queries with DBD::Pg fail with: Cannot execute until previous async query has finished

Hello, I'm using CentOS 5.5 Linux (same as Redhat 5.5) with stock perl v5.8.8 and have installed DBD-Pg-2.17.1 via CPAN shell and I'm using postgresql-server-8.4.5-1PGDG.rhel5 and friends. I have prepared a simple test case demonstrating my problem - it is listed at the bottom. My code works ok, when I remove {pg_async => PG_ASYNC} M...