Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # SQL.Text := 'select';
- # SQL.Add(' bh.chart');
- # SQL.Add(' , lb.billing');
- # SQL.Add(' , hh.ins_code');
- # SQL.Add(' , hh.type as who_billed');
- # SQL.Add(' , hh.date_printed as last_billed_date');
- # SQL.Add(' , bh.total as balance');
- # SQL.Add(' , (');
- # SQL.Add(' select max(bd.service_date_1)');
- # SQL.Add(' from billing_details bd');
- # SQL.Add(' join transaction_classes tc on bd.transaction_code = tc.transaction_code');
- # SQL.Add(' where');
- # SQL.Add(' bd.billing = bh.billing');
- # SQL.Add(' and transaction_class = ''P''');
- # SQL.Add(' ) as last_payment_date');
- # SQL.Add('from last_billed lb');
- # SQL.Add(' join billing_headers bh on bh.billing = lb.billing');
- # SQL.Add(' join history_headers hh on lb.unique_id = hh.unique_id');
- # SQL.Add('where');
- # SQL.Add(' bh.total <> 0');
- # SQL.Add('order by hh.ins_code, last_payment_date');
- # OpenWithDates(qryActivities);
- def parse_lines(lines)
- lines.each do |line|
- a = line.gsub("\t", " ").split("\'")
- sql = a.slice(1, a.size - 2)
- if sql.nil? or sql.empty?
- if a[0].downcase =~ /openwithdates/
- # NOP
- elsif a[0].downcase =~ /getdateclause/
- puts ' bd.entry_date BETWEEN :start_date AND :end_date'
- else
- puts "-- #{line}"
- end
- else
- sql.each_with_index{|e,i| sql[i] = "'" if e == ""}
- puts sql.join('').gsub("''", "'")
- end
- end
- end
- def load_file(filename)
- File.open(filename){|f| f.read.split("\n")}
- end
- if ARGV[0].nil?
- puts "usage: ruby convert.rb filename"
- exit
- end
- if !File.exist?(ARGV[0])
- puts "file does not exist: '#{ARGV[0]}'"
- exit
- end
- parse_lines load_file(ARGV[0])
Add Comment
Please, Sign In to add comment