Sponsored Content
Top Forums Shell Programming and Scripting perl DBI: populate a scalar from a select statement Post 302372316 by durden_tyler on Tuesday 17th of November 2009 03:58:01 PM
Old 11-17-2009
Code:
$
$ mysql -u test -ptest -e "select nic from t where ip = '3.3.3.3'" test
+------+
| nic  |
+------+
| CE0  |
+------+
$
$ cat -n fetchone.pl
     1  #!/usr/bin/perl -w
     2  use DBI;
     3  $dbh = DBI->connect('dbi:mysql:test','test','test');
     4  my $nic = $dbh->selectrow_array("select nic from t where ip = '3.3.3.3'");
     5  print "nic = $nic\n";
     6
$
$ perl fetchone.pl
nic = CE0
$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies

2. Shell Programming and Scripting

perl scalar variable in backquoted string

hi I've been searching all over the internet to simply do the following: $tempfile = "/usr/school/tempfile.dat"; $myvar = param('add'); ###add is the variable assigned to a popup menu `ls -l $myvar * >> $tempfile` ###I also tried `ls -l ${myvar}* >>$tempfile` open(ADDLIST,... (6 Replies)
Discussion started by: mehdi9
6 Replies

3. Shell Programming and Scripting

scalar variable assignment in perl + { operator

When reading over some perl code in a software document, I came across an assignment statement like this $PATH = ${PROJECT}/......./.... In this particular form of scalar variable assignment, what does the curly braces operators do ? Also, what is the benefit in doing scalar assignment this... (3 Replies)
Discussion started by: JamesGoh
3 Replies

4. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

5. Shell Programming and Scripting

Installing Perl DBI and DBD

Hi, i have some queries on installing the Perl DBI and the DBD Oracle. I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI Perl Makefile.PL make make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies

6. Shell Programming and Scripting

populate PERL Hash

Hello I am new to perl and learning ...can you please explain why am i getting this error...as myHash is defined right above the code and I think it should be avilable in the sub function. Here is my code: <code> #!/usr/bin/perl use warnings; use strict; %myHash=(); sub... (2 Replies)
Discussion started by: uandme2k2
2 Replies

7. Shell Programming and Scripting

connect to MySQL from Perl using DBI

Hi, I want to connect perl with the mysql to select and so on but the connection don't work code #!/usr/bin/perl BEGIN { # PERL MODULES WE WILL BE USING use DBI; $dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;} #... (1 Reply)
Discussion started by: eng_shimaa
1 Replies

8. Shell Programming and Scripting

perl: help with DBI

Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough) $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

9. Shell Programming and Scripting

Perl DBI error

Hi All, I installed DBI module in a non INC location and using it in my script via "use lib". But it throw the below error at the "use DBI" step. Please help Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies

10. Shell Programming and Scripting

Perl : converting file to different scalar elements

I have a text file containing 2 exec statements as below and trying to store the below 2 execs into 2 different scalar variables in perl. /* ICD Dist, Total */ /* need to export to Excel, sheet=ICD_Dist__Total */ exec( 'select sum(count(*)) cast(count(*)*100.0/sum(count(*)) over() as... (7 Replies)
Discussion started by: scriptscript
7 Replies
Jifty::DBI::Handle::Pg(3pm)				User Contributed Perl Documentation			       Jifty::DBI::Handle::Pg(3pm)

NAME
Jifty::DBI::Handle::Pg - A Postgres specific Handle object SYNOPSIS
DESCRIPTION
This module provides a subclass of Jifty::DBI::Handle that compensates for some of the idiosyncrasies of Postgres. METHODS
connect connect takes a hashref and passes it off to SUPER::connect; Forces the timezone to GMT, returns a database handle. insert Takes a table name as the first argument and assumes that the rest of the arguments are an array of key-value pairs to be inserted. In case of insert failure, returns a Class::ReturnValue object preloaded with error info id_sequence_name TABLE Takes a TABLE name and returns the name of the sequence of the primary key for that table. blob_params column_NAME column_type Returns a hash ref for the bind_param call to identify BLOB types used by the current database for a particular column type. The current Postgres implementation only supports BYTEA types. apply_limits STATEMENTREF ROWS_PER_PAGE FIRST_ROW takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW; _make_clause_case_insensitive column operator VALUE Takes a column, operator and value. performs the magic necessary to make your database treat this clause as case insensitive. Returns a column operator value triple. distinct_query STATEMENTREF takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set. canonical_true The canonical true value in Postgres is 't'. canonical_false The canonical false value in Postgres is 'f'. SEE ALSO
Jifty::DBI, Jifty::DBI::Handle, DBD::Pg perl v5.14.2 2011-04-26 Jifty::DBI::Handle::Pg(3pm)
All times are GMT -4. The time now is 12:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy