Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. open(OUTFILE, "> ./outputfile.csv");
  2.  
  3. my($dbh,$sth);
  4. $dbh = DBI->connect("xxx")
  5.  
  6. my $sqlGetEid = "
  7.  
  8. select *
  9. from Table_1
  10. where MARKET = 'Chicago' and DATETIMELOCAL >= '22-FEB-2015' and DATETIMELOCAL < '01-MAR-2015'
  11.  
  12. ";
  13.  
  14. my $curSqlEid = $dbh->prepare($sqlGetEid);
  15.  
  16. $curSqlEid->execute();
  17.  
  18. my $counter = 0;
  19. my $delimiter = ',';
  20. my $fields = join(',', @{ $curSqlEid->{NAME_lc} });
  21. print "$fieldsn";
  22. printf OUTFILE "$fieldsn";
  23.  
  24. while (my @row = $curSqlEid->fetchrow_array) {
  25. my $csv = join(',', @row)."n";
  26. printf OUTFILE "$csv";
  27. $counter ++;
  28. if($counter % 10000 == 0){
  29. print $csv, "n";
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement