
007bindu
New User
Aug 19, 2008, 1:44 AM
Post #1 of 3
(4548 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
|