use DBI; use strict; use DBI::DBD::SqlEngine; use AnyData; use DBD::AnyData; unlink "QueryResult.txt"; print "\nEnter the input file name with path info : \n"; chomp( my $dir = ); my ($directory,$file_name); if($dir=~m/(.*\\)([^\\]+)$/is) { $directory=$1; $file_name=$2; $file_name=~s/\.[^>]*$//igs; } $dir =~ s!\\!\/!igs; print "\nEnter the file delimiter(Pipe,CSV,Tab) : \n"; chomp( my $deli = ); print "\nDo you want to count the number of lines in the input file(1=Yes,0=No) \n"; chomp( my $depend_flag = ); if($depend_flag==1) { open(IN,"$dir"); my @str = ; close(IN); my $lines=scalar(@str); print "The number of lines in $dir is $lines.\n"; } query: print "\nEnter the query to execute : \n"; chomp( my $query = ); my $dbh = DBI->connect('dbi:AnyData:'); $dbh->func( "$file_name", "$deli", "$dir",'ad_catalog'); my $sth = $dbh->prepare("$query"); $sth->execute(); print "\n"; while (my $row = $sth->fetch) { print "@$row\n"; open(APPEND,">>$directory/QueryResult.txt"); print APPEND "@$row\n"; close(APPEND); } print "\nDo you want to execute another query(1=Yes,0=No) \n"; chomp( my $flag = ); if($flag==1) { goto query; } else { exit; }