CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
Looping the execution of multiple SQL queries

 



007bindu
New User

Aug 19, 2008, 1:44 AM

Post #1 of 3 (5627 views)
Looping the execution of multiple SQL queries Can't Post

Hi

i have a .txt file which contains a set of sql queries, in the below format.

ex: 1: Select BenchmarkVersion from PABenchmarkView WHERE StageType='Received' AND BenchmarkID IN('testcase1-benchmark1');
2: Select BenchmarkID From PABenchmarkView WHERE StageType='Received'AND BenchmarkID IN('MultiBM-1', 'MultiBM-2')AND McAfeeSupplied='False';
3: Select * from PAAuditBenchmarkResultScore where BenchmarkResultAutoID = (Select BenchmarkResultAutoID from PAAuditBenchmarkResult where BenchmarkId = 'waiver_bench54');
4: Select Title from PACpeDictionary where DisplayInUI=1;

I want to read and store the query to a temp variable. So that i can execute each query from a common sql function.

My SQL funtion is :

package SQLquery;
use DBI;
#use Cwd;

$user="";
$password="";

$DSN="MQIS";

connect_SQLDataBase_WinAuth();
Func1();

sub connect_SQLDataBase_WinAuth
{
$dbh = DBI->connect("dbi:ODBC:$DSN", $user, $password);
}


sub Func1()
{
#### read all the sql queries from the text file to temp variable and start executing it for each array value
$query=("Select Title from PACpeDictionary where DisplayInUI=1; \n");
$sth = $dbh->prepare($query);
$sth->execute;
my $queryoutput;
while (($queryoutput)=$sth->fetchrow_array())
{
print ("\n $queryoutput \n");
}
}

Thanks in Advance

Bindu

9900205942


sycoogtit
User

Sep 6, 2008, 9:47 PM

Post #2 of 3 (5153 views)
Re: [007bindu] Looping the execution of multiple SQL queries [In reply to] Can't Post

Why are there so many double-posted threads on this site? I replied to this already in the regex forum. Granted, the regex forum doesn't seem to be the right forum for this question, but that's where I saw it first.

--
http://bunsooter.com


KevinR
Veteran


Sep 7, 2008, 1:19 PM

Post #3 of 3 (5119 views)
Re: [sycoogtit] Looping the execution of multiple SQL queries [In reply to] Can't Post


In Reply To
Why are there so many double-posted threads on this site? I replied to this already in the regex forum. Granted, the regex forum doesn't seem to be the right forum for this question, but that's where I saw it first.


Because people think if they post the same question across multiple forums they will get a reply sooner. There are also no moderators active on this forum so the cross-posted questions are not removed or moved into the correct forum.

Regards,
Kevin
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives