For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2004 > win32 odbc test script









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author win32 odbc test script
joe

2004-06-27, 3:56 pm

Hi i just wrote a little quick and dirty script to query odbc, i could not
find anything similar so i wrote this.

use Win32::ODBC;
print "Enter ODBC data source: ";
$myprompt = <STDIN>;
chop($myprompt);

my($db) = new Win32::ODBC("$myprompt");

while (true){
print "> ";
$myprompt = <STDIN>;
chop($myprompt);

if ($myprompt eq "quit"){
$db->Close();
exit;
}

$db->Sql("$myprompt");
my(@fields) = $db->FieldNames;

while ($db->FetchRow()) {
my(%data) = $db->DataHash();
foreach $field (sort @fields) {
$test = "$data{$field} ";
print "$test";
}
print "\n";

}
}

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com