I'm trying to pass table names to a sub that gets all the field names of that table, stores them into an array, and then uses that array in conjunction with the fetchrow of another sql query to display the data in those fields. Here's the code I have now:
Examples of sub calls with table names as the parameter:
shamoo("reqhead_rec");
...
I am using Perl to collect data from several logfiles and store it into an Oracle database on the same Windows 2003 host I am running my script on. Is it better to use the Perl DBI module or to set up a system DSN and use ODBC?
Thank you ahead of time!
Michael
...
I need to connect to a secure SQL Server database using Perl DBI. I need to find a way to authenticate the user securely (without fear of eavesdropping, and without storing passwords on the client side). I'm using SQL Server 2008 on Windows Server 2008, and Perl 5.10 on XP.
SQL Server supports encrypted connections via something calle...
I'd like to know if it's possible to execute more than one SQL statement within a single execute() or do() call using DBD::Oracle via Perl DBI. Example:
# Multiple SQL statements in a single query, separated by a ";"
$sql = 'UPDATE foo SET bar = 123; DELETE FROM foo WHERE baz = 456';
$sth = $dbh->prepare($sql);
$sth->execute;
# ...or...
Background
Below is a typical piece of Perl code (sample.pl for the sake of discussion) that grabs submitted form data using CGI, passes the form data to DBI which will then retrieve the required rows from MySQL and then hands the results over to Template Toolkit to render into a HTML document for display.
Code listing for sample.pl :
...
Hi,
is there an easy way to timeout an SQL statement so that it will fail instead of waiting (e.g. deliver an empty result set or an error message or whatever else) so I can let a job's ressource reservation fail and give another one a chance? I'm looking for some DBI option I've overlooked so far; sending SIGALRMs to myself to commit su...
My delicious-to-wp perl script works but gives for all "weird" characters even weirder output.
So I tried
$description = decode_utf8( $description );
but that doesnt make a difference. I would like e.g. “go live” to become “go live” and not “go live†How can I handle unicode in Perl so that this works?
UPDATE: I found the prob...
I'm developing a relatively small application to talk to PostgreSQL, and wanted to get some feedback on how far is too far to go with regards to protecting against SQL injection.
The application is in Perl and does not use any ORM modules (just DBI). The SQL statements are constructed in the typical fashion with placeholders:
my $sql ...
I have a query on a PostgreSQL system returning a boolean:
my $sth = $dbh->prepare("select 'f'::boolean");
$sth->execute;
my @vals = $sth->fetchrow_array;
According to the DBD::Pg docs,
The current implementation of
PostgreSQL returns 't' for true and
'f' for false. From the Perl point of
view, this is a rather unfortunate
...
Hello,
I'm trying to read data from SQL Server database using Perl and the DBI module. My intention is to read the data and print it into a text file (comma separated). When I do this, I get the result like this:
var1,var2,var3
40406,20 ,783
50230,78 ,680
50230,78 ,680
50230,78 ,680
50230,78 ,680
So there is a whitespace between the ...
I am running a SQLite database within a Perl CGI script which is being accessed by DBD::SQLite. This is being run as a straight CGI on Apache.
The DBI connection works fine and selects are able to be run. However, when I attempt to do an insert I get a die with the following error:
DBD::SQLite::st execute failed: unable to open databa...
Seeing some strange behavior, whereby connecting to Oracle database, and then calling external function, the value of $? is always -1.
Problem machine is running standard AIX5.3, with DBD::Oracle 1.20 and DBI 1.602.
#!/usr/bin/perl -w
use DBI;
CORE::system "pwd";
print "Before connect: $?\n";
DBI->connect('dbi:Oracle:', 'pwd', 'pwd');
...
I have tried with Perl fork manager and DBI . But i got the error DBD::mysql::st execute failed: Lost connection to MySQL server during query .
Here the sample code: I want make query between low to high value (i have spitted int 10k records)
use Parallel::ForkManager;
my $pm = new Parallel::ForkManager(50);
my $db = krish::DB->new or...
I have a sql file test.sql used to run some SQL (create object / update / delete / insert) that can look like this
CREATE TABLE test_dbi1 (
test_dbi_intr_no NUMBER(15)
, test_dbi_name VARCHAR2(100);
UPDATE mytable
SET col1=1;
CREATE TABLE test_dbi2 (
test_dbi_intr_no NUMBER(15)
, test_dbi_name V...
I'm willing to write a subset of Perl's DBI interface for libodbc (or unixODBC) in C++.
I believe doing so will allow me concentrate better on my goal.
BTW, I prefer avoiding to reinvent the wheel, if of course something similar is already out there.
...
I have an issue where an application is randomly dying during a DBI call. We cannot reliably reproduce this in our test or acceptance environment, so I am required to monitor it on our production system to try to figure out what is happening.
I am logging all the DBI traffic via the DBI_TRACE environment variable.
DBI_TRACE=3=dbi.log s...
I want to do VACUUM at a certain time on a SQLite database under Perl, but it always says
DBD::SQLite::db do failed: cannot VACUUM from within a transaction
So how do I do this?
my %attr = ( RaiseError => 0, PrintError => 1, AutoCommit => 0 );
my $dbh = DBI->connect('dbi:SQLite:dbname='.$file'','',\%attr)
or die $DBI::errstr;...
How do I using a variable for the name of a table in a DBI query? I know how to use placeholders as part of the where clause, but how do I do this for the table name?
I would like to do something like this:
my $table_name='table1';
my $query = $dbh_cgi->prepare("select * from ?");
$query->execute($table_name);
So far, I end up get...
We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5) from Perl. As long as the absolute values are .0001 or greater, it is working. However, when the values go to the 5th decimal place, Perl starts storing them in exponential format (-9e-05 instead of -0.00009), and then we get the error "Error converting ...
Can anyone provide syntax to create a table trigger preferably with DBI's do() method. It doesn't seem to like me putting everything on one line. Not sure what i'm doing wrong. Here's what I've got:
$dbh->do("CREATE TABLE image(img_id integer primary key, md5sum text, path text, name text, date DATE)");
$dbh->do("CREATE TRIGGER insert_i...