Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Win32::ODBC Multiple Queries

by Nitrox (Chaplain)
on Dec 18, 2002 at 17:39 UTC ( #220904=note: print w/replies, xml ) Need Help??

in reply to Win32::ODBC Multiple Queries

I would suggest not opening your second database connection from inside the while() loop.

Also, if your end goal is to get the results for multiple queries I'd suggest looking into SQL syntax, specifically join's.


Replies are listed 'Best First'.
Re: Re: Win32::ODBC Multiple Queries
by Willman023 (Scribe) on Dec 18, 2002 at 17:54 UTC
    Thanx Nitrox, turns out I was moving the iterator($db2->Data()) out of the second while loop. This caused it not to output anything. Another case of programmer error!

    So that error being fixed, I tryed to tie 3 quieries together like so but now I'm getting a Runtime Error. I get the first value to print out and then I get that dreaded Runtime Error. Is it possible that I'm exceding a buffer or something? Can anybody explain why that could happen? Thanks again!

    #!/opt/perl/bin/perl use Win32::ODBC; use strict; my $outdir="//Cmdsrv02/EPIC_Users/Group_Share/Database/meetings/script +s/"; #MAKE CONNECTION AND QUERY ACCESS DATABASE my $connstring = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=//Cmdsrv0 +2/EPIC_Users/Group_Share/Database/meetings/meetings.mdb"; my $connstring2 = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=//Cmdsrv +02/EPIC_Users/Group_Share/Contacts/contacts.mdb"; my $db = new Win32::ODBC($connstring); my $db2 = new Win32::ODBC($connstring2); my $db3 = new Win32::ODBC($connstring2); $db->Sql("SELECT * FROM meetings INNER JOIN groups ON meetings.group_i +d=groups.group_id"); #OPEN EXTERNAL LOGFILE open(LOGFILE, ">$outdir/events.txt"); while ($db->FetchRow()) { #DB Variables my $meeting_id="meeting_id", my $meeting_type_id="meeting_type_id", my + $group_id="group_id", my $group_name="group_name", my $contact1_id=" +contact1_id", my $contact2_id="contact2_id", my $title="title", my $d +etails="details", my $date_begin="date_begin", my $date_end="date_end +", my $time_begin="time_begin", my $time_end="time_end", my $duration +="duration", my $call_in_number="call_in_number", my $call_in_code="c +all_in_code", my $location="location", my $date_last_published="date_ +last_published", my $discipline="discipline"; my $discipline_id = "di +scipline_id"; my $discipline = "discipline"; $meeting_id=$db->Data($meeting_id); $meeting_type_id=$db->Data($meetin +g_type_id); $group_id=$db->Data($group_id); $group_name=$db->Data($gr +oup_name); $contact1_id=$db->Data($contact1_id); $contact2_id=$db->Da +ta($contact2_id); $title=$db->Data($title); $details=$db->Data($detai +ls); $date_begin=$db->Data($date_begin); $date_end=$db->Data($date_en +d); $time_begin=$db->Data($time_begin); $time_end=$db->Data($time_end +); $duration=$db->Data($duration); $call_in_number=$db->Data($call_in +_number); $call_in_code=$db->Data($call_in_code); $location=$db->Data +($location); $date_last_published=$db->Data($date_last_published); #INTERNAL QUERY $db2->Sql("SELECT discipline_id FROM groups_in_disciplines WHERE group +_id=$group_id"); $db2->FetchRow(); $discipline_id=$db2->Data($discipline_id); $db3->Sql("SELECT discipline FROM disciplines WHERE discipline_id=$dis +cipline_id"); $db3->FetchRow(); $discipline = $db3->Data($discipline); print LOGFILE $discipline, "\t"; #print LOGFILE $meeting_id, "\t"; #print LOGFILE $meeting_type_id, "\t"; #print LOGFILE $group_id, "\t"; #print LOGFILE $group_name, "\t"; #print LOGFILE $contact1_id, "\t"; #print LOGFILE $contact2_id, "\t"; #print LOGFILE $title, "\t"; #print LOGFILE $details, "\t"; #print LOGFILE $date_begin, "\t"; #print LOGFILE $date_end, "\t"; #print LOGFILE $time_begin, "\t"; #print LOGFILE $time_end, "\t"; #print LOGFILE $duration, "\t"; #print LOGFILE $call_in_number, "\t"; #print LOGFILE $call_in_code, "\t"; #print LOGFILE $location, "\t"; #print LOGFILE $date_last_published, "\n"; $db2->Close(); $db3->Close(); } close LOGFILE; $db->Close(); exit();


    Perl - the breakfast of Champions!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://220904]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2023-06-08 22:37 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (35 votes). Check out past polls.