?
Solved

How can I store Sql query result in variable in perl?

Posted on 2008-11-02
3
Medium Priority
?
494 Views
Last Modified: 2012-06-21
I am executing following SELECT query from my perl program and I am using DBI interface
my $test=$dbh->prepare("SELECT AVG(diff) FROM data WHERE key1='s' and key2='i'");
$test-> execute();

The above query , if executed in SQL query browser generate average result of column 'diff' which I want to store in variable in perl for further use

I have idea of dump_results function provided by DBI as one of the option but doesn't seems to work for me
0
Comment
Question by:saini_er
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Umesh
ID: 22864908
Try this..

@row = $sth->fetchrow_array();
 
$myVar = $row[0];

Open in new window

0
 
LVL 26

Accepted Solution

by:
Umesh earned 2000 total points
ID: 22864911
oops...try this..

@row = $test->fetchrow_array();
 
$myVar = $row[0];
0
 

Author Closing Comment

by:saini_er
ID: 31512593
Thanks a lot .it worked like a charm
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Six Sigma Control Plans
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question