/[SQL2XLS]/sql2xls.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sql2xls.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by dpavlin, Thu Nov 6 10:49:02 2008 UTC revision 28 by dpavlin, Thu Dec 27 12:57:01 2012 UTC
# Line 99  $sql_dir .= "/$reports_path" if -e "$sql Line 99  $sql_dir .= "/$reports_path" if -e "$sql
99    
100  require_config;  require_config;
101    
102  warn "# reading SQL queries from $sql_dir\n" if $debug;  warn "SQL queries from $sql_dir\n";
103    
104  opendir(DIR, $sql_dir) || die "can't opendir $sql_dir: $!";  opendir(DIR, $sql_dir) || die "can't opendir $sql_dir: $!";
105  my @sql_files = sort grep { /\.sql$/i && -f "$sql_dir/$_" } readdir(DIR);  my @sql_files = sort grep { /\.sql$/i && -f "$sql_dir/$_" } readdir(DIR);
# Line 195  foreach my $sql_file (@sql_files) { Line 195  foreach my $sql_file (@sql_files) {
195    
196          foreach my $sql ( split(/;/, $full_sql ) ) {          foreach my $sql ( split(/;/, $full_sql ) ) {
197    
198                  warn "SQL: $sql\n" if $debug;                  warn "SQL: $sql\n";
199    
200                  my $sth = $dbh->prepare($sql);                  my $sth = $dbh->prepare($sql);
201                  $sth->execute();                  $sth->execute();
202    
203                  next unless $sth->{NAME}; # $sth->rows doesn't work for insert into with MySQL                  next unless $sth->{NAME} && $sth->rows > 0; # $sth->rows alone doesn't work for insert into with MySQL
204    
205                  my @types = eval {                  my @types = eval {
206                          map { $dbh->type_info($_) ? $dbh->type_info($_)->{TYPE_NAME} : '?' } @{ $sth->{TYPE} };                          map { $dbh->type_info($_) ? $dbh->type_info($_)->{TYPE_NAME} : '?' } @{ $sth->{TYPE} };
# Line 224  foreach my $sql_file (@sql_files) { Line 224  foreach my $sql_file (@sql_files) {
224                                          warn "## heuristic date time: $1T$2\n" if $debug;                                          warn "## heuristic date time: $1T$2\n" if $debug;
225                                          $worksheet->write_date_time( $row, $col, "$1T$2", $date_format );                                          $worksheet->write_date_time( $row, $col, "$1T$2", $date_format );
226                                  } else {                                  } else {
227                                            $data = "'" . $data if $data =~ m/^=/; # escape data which looks like formula
228                                          $worksheet->write($row, $col, _c( $data ) );                                          $worksheet->write($row, $col, _c( $data ) );
229                                  }                                  }
230                          }                          }

Legend:
Removed from v.23  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26