I based my code on the answer to the question Access get all tables, but am getting the following error:
DBD::ODBC::st execute failed:
[Microsoft][ODBC Microsoft Access
Driver] Record(s) cannot be read; no
read permission on 'MSysObjects'.
(SQL-42000) at direct.pl line 22.
[Microsoft][ODBC Microsoft Access
Driver] Reco...
I'm using DBI to query a SQLite3 database. What I have works, but it doesn't return the columns in order. Example:
Query: select col1, col2, col3, col4 from some_view;
Output:
col3, col2, col1, col4
3, 2, 1, 4
3, 2, 1, 4
3, 2, 1, 4
3, 2, 1, 4
...
(values and columns are just for illustration)
I know this i...
I am writing some Perl scripts to manipulate large amounts (in total about 42 million rows, but it won't be done in one hit) of data in two PostgreSQL databases.
For some of my queries it makes good sense to use fetchall_hashref because I have synthetic keys. However, in other instances, I'm going to have use an array of three columns ...
Hello! Why does reading from __DATA__ work and reading from the file doesn't (Loose unescaped quote)?
#!/usr/bin/env perl
use warnings; use strict; use 5.010;
use DBI;
my $table = 'klassik_CD.csv';
print qx(cat $table);
print qq{\n"data" or "Enter" : };
chomp( my $aw = <> );
if ( $aw eq 'data' ) {
$table = 'te_mp_fi_le.csv';
...
I want to adopt logging within several utility classes, e. g. DBI. What is the best practice to do it with Log::Log4perl?
I think it is OK to subclass DBI (say, MyDBI) and override some methods there to make them do the logging. But there's a problem with categories. If you create a logger with
Log::Log4perl->get_logger(ref $self || $s...
my $dblinks = '';
$dblinks = $dbh->selectcol_arrayref("select db_link from db_links where ticket=\'LOW\'");
my $success = 0;
for my $dblink (@$dblinks) {
$success = eval {
my ($ret) = $dbh->selectrow_array("select 1 from "
. $dbh->quote_identifier($dblink, 'SYSIBM', "SYSDUMMY1") );
$ret;
};
if ($success) {
&Loggi...
my ($ret) = $l_dbh->selectrow_array("select dummy from "
. $l_dbh->quote_identifier($dblink, 'SYSIBM', "SYSDUMMY1") );
$ret;
};
...
Hi all,
Using DBI::DatabaseHandle#execute or DBI::DatabaseHandle#prepare it's not possible to run an sql script (with mutiple sql statments). It fails with the following error :
ERROR: cannot insert multiple commands into a prepared statement
I tried to use the "unprepared" way using DBI::DatabaseHandle#do (the doc says it "goes stra...
Is there a way for DBI to connect to a RedBrick database? I don't see a driver anywhere, and there is very little discussion of this.
Thanks
...
I need to use Ruby to create some SQL statements for a MySQL database. Ruby will never connect to the database. The SQL statements will be sent to another site and executed against the MySQL database.
Since the machine running Ruby does not have a connection to the database, is it possible to use DBI's prepare statement without creati...
I am a bit new to the Devel::Cover module, but have found it very useful in making sure I am not missing tests.
A problem I am running into is understanding the report from Devel::Cover. I've looked at the documentation, but can't figure out what I need to test to get 100% coverage.
Edit - I should make it clear that I am not sayin...
I'm having a problem with executing a stored procedure from Perl (using the DBI Module). If I execute a simple SELECT * FROM table there are no problems.
The SQL code is:
DROP FUNCTION IF EXISTS update_current_stock_price;
DELIMITER |
CREATE FUNCTION update_current_stock_price (symbolIN VARCHAR(20), nameIN VARCHAR(150), currentP...
I have a problem when I use Apache::DBI in child processes. The problem is that Apache::DBI provides a single handle for all processes which use it, so I get
DBD::mysql::db selectall_arrayref
failed: Commands out of sync; you
can't run this command now at
/usr/local/www/apache22/data/test-fork.cgi
line 20.
Reconnection does...
What's with this?
my $sth = $dbh->prepare(q~
select 'hello'::text as my_text_column
~);
$sth->execute;
print $$sth{TYPE}[0]; # prints -1, expected 12
I can select 5 and it returns the correct type (4, for integer) or cast it like select 5::numeric(4, 2) and get back 3. Why doesn't it like text columns?
...
Here's a snippit of perl code:
sub insert_timesheet {
my $dbh = shift;
my $entryref = shift;
my $insertme = join(',', @_);
my $values_template = '?, ' x scalar(@_);
chop $values_template;
chop $values_template; #remove trailing comma
my $insert = "INSERT INTO timesheet( $insertme ) VALUES ( $values_template...
Hi, Could you plesae teach me how to Loop & rename MySQL table in Perl. Thanks.
my code snippet attached
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(
'DBI:mysql:database=dbdev;host=localhost',
'dbdev',
'dbdevpw',
{ RaiseError => 1, AutoCommit => 1 },
);
my $sql = RENAME TABLE old_table TO new_ta...
I've downloaded the IBM DBI package, including all the packages in my program as specified in the docs. I've cataloged the DB and can connect to it from the command line, but my DBI connect fails:
$dbh = DBI->connect ("dbi:DB2:warehou1", user, pass) or die "Can't connect to sample database: $DBI::errstr";
Can't connect to sample datab...
I'm having issues with getting DBI's IBM DB2 driver to work with mod_perl. My test script is:
#!/usr/bin/perl
use strict;
use CGI;
use Data::Dumper;
use DBI;
{
my $q;
my $dsn;
my $username;
my $password;
my $sth;
my $dbc;
my $row;
$q = CGI->new;
print $q->header;
print $q->start_html();
$d...
I'm trying to setup a Perl development environment on my Mac laptop and have been having a really hard time getting it working. I thought I had everything configured correctly but when I try to run a sample script it is reporting errors with the DBI module and can't access the DB.
Here is what is reported in the Apache error logs:
[Fri...
In this script I have problems with file-name-extensions:
if I use /home/mm/test_x it works, with file named /home/mm/test_x.csv it doesn't:
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;
my $table_1 = '/home/mm/test_1.csv';
my $table_2 = '/home/mm/test_2.csv';
#$table_1 = '/home/mm/test_1';
#$table_2 = '/home/mm/tes...