A while back I was looking for a way to insert values into a text field through isql
and eventually found some load command that worked out for me.
It doesn't work when I try to execute it from Perl. I get a syntax error. I have tried two separate methods and both are not working so far.
I have the SQL statement variable print out at...
I have a ruby script which I run using the JRuby Interpreter.
The script connects to a Sybase database using DBI and Sybase JDBC (jTDS3.jar and jconn3.jar)
My problem is that I have a select query that alters the column names of table.
For example:
SELECT
t.TRANSACTION as 'business_transaction',
t.TRADE_CURRENCY as 'currency',
t.CURREN...
I have the following (returning two separate result sets) being successfully executed from a proc but cannot do the same when executing this as a basic query.
SELECT * FROM persons;
SELECT * FROM addresses;
Possible? What's the syntax?
EDIT:
I am using Ruby's DBI library:
dbh.query("SELECT * FROM persons; SELECT * FROM addresses;"...
I am writing small snippets in Perl and DBI (SQLite yay!)
I would like to log some specific queries to text files having the same filename as that of the table name(s) on which the query is run.
Here is the code I use to dump results to a text file :
sub dumpResultsToFile {
my ( $query ) = @_;
# Prepare and execute the query
...
I don't know if "variadic" is actually the right word, but I'm talking about things that can take a list of values, like IN(). If you've been working with DBI for long, you've probably tried to do this:
(Note: All examples extremely simplified for brevity)
my $vals = join ', ', @numbers;
my $sth = $dbh->prepare( "SELECT * FROM mytbl WH...
I have a .accdb file on my local machine and I am trying to connect to it and read some data from 3 tables within the DB. How do I establish the connection using Perl?
So far I have scraped together this much for MS Access, but I am getting errors saying that I am not using the correct driver. Any ideas?
my $msaccess_dbh = DBI->connect...
Using a perl script (Perl 5.8.6), I'm connecting to Sybase dataserver.
Looking for the following:
How many connections are currently opened by the script.
Generic (non-dataserver specific) Error handling modules/mechanism
When executing a stored proc, it returned the following error message.
DBD::Sybase::st execute failed: Serve...
The following code seems to be just too much, for getting a single count value.
Is there a better, recommended way to fetch a single COUNT value using plain DBI?
sub get_count {
my $sth = $dbh->prepare("SELECT COUNT(*) FROM table WHERE...");
$sth->execute( @params );
my $($count) = $sth->fetchrow_array;
$sth->finish;
ret...
I am trying to run simple perl dbi example script to connect to mysql database and do some inserts.
Code:
#! bin/usr/perl -w
use strict;
use warnings;
use DBI();
my $dbh = DBI->connect(
"DBI:mysql:database=SPM;host=IP Address", "username", "password",
{'RaiseError'=>1}
);
my $dbh->do(
'INSERT INTO payment_methods(name, ...
I'm using Perl's DBI module. I prepare a statement using placeholders, then execute the query.
Is it possible to print out the final query that was executed without manually escaping the parameters and dropping them into the placeholders?
Thanks
...
cant open perl script "Makefile.PL":No such file or directory.
While installing perl-DBI im getting this error. kindly suggest some solution.
...
I need to insert values in database using Perl's DBI module. I have parsed a file to obtain these values and hence these values are present in an arrays, say @array1, @array2, @array3. I know how to insert one value at a time but not from an arrays.
I know insert one value at a time:
$dbh = DBI->connect("dbi:Sybase:server=$Srv;database...
I have to compare columns of tables located in two different databases in two different servers. So far, I know how to connect to one server & one database using Perl script. Is it possible to connect to two different servers using Perl's DBI module? If so, how?
...
I am required to pull out rows corresponding to column name. The rows being pulled out correspond to address in array @values. Following is my code:
use strict;
use DBI;
open (FH, "/user/address") or die $!;
my@values=<FH>;
close(FH);
my @names;
my $query = "Select name from table where address = ?";
my $sth = $dbh->prepare( $query ) ...
I need to insert values from a hash into a database. Following is the code template I have to insert values in table1 column key and value:
use DBI;
use strict;
%hash; #assuming it already contains desired values
my $dbh = DBI->connect(
"dbi:Sybase:server=$Srv;database=$Db",
"$user", "$passwd"
) or die sprintf 'could not c...
I can query the SQL server DB fine. The problem happens when I try and query a view.
I'm not trying to do anything crazy:
$sql = 'select * from location_v';
$stj = $db_destination->prepare($sql);
It keeps dying on the prepare line. Here's what I'm getting back (which isn't all that useful):
DBD::ODBC::db prepare failed: (DBD: st...
I have a hash and I am trying to insert its values into database. Hash is defined as follows:
my %hash = (
1 => 'First Word',
2 => 'Second Word is correct',
0 => 'Third word does not exist',
);
I do not know how to insert values in a database using hashes. I notice my question i...
I am trying to install DBD::Oracle using the CPAN shell in Strawberry Perl. I initially experienced an error because the Makefile could not locate an OCI library, so I installed the instant client from Oracle. I thought this would fix the problem, but now I get a large mixture of errors and warnings from Oracle.h, dbdimp.h, Oracle.c, O...
Environment:
Rails 2.3.2
DBI 0.4.1
DBD/ODBC 0.2.4
Scenario:
I have a Rails app that imports most of it's data from external SQL DBs into the Rails SQL DB via regular batch jobs. Those batch jobs start by loading the Rails environment, then proceed to make direct database connections via RubyDBI. Once I connect, I run select statements t...
I am trying to implement sql LIKE qualifier with placeholders for a set of values. I know how to do it for one particular value as follows:
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Sybase:server=$Srv;database=$Db", "$user", "$passwd") or die "could not connect to database";
my $query = "Select key, first_name from names where la...