fix a few memory leaks and cppcheck detected errors - more in bugreport
[client-tools.git] / src / game / server / database / migration / make_insert.pl
blob60e3cc65a2abbabe5215f841b7e31daad44c7df7
1 #!/usr/bin/perl
3 # Given an export from Postgresql, convert it into a series of insert statements
4 # that Oracle can understand.
5 # Assumes the data is stored in files name <tablename>.txt
7 # This is suitable for small databases, but should not be used for large databases
8 # because it inserts the data one row at a time.
10 foreach $filename (@ARGV)
12 print STDERR $filename."\n";
14 open (INFILE,$filename);
15 $tablename=$filename;
16 $tablename =~ s/\.txt//;
18 while (<INFILE>)
20 chop;
21 $_="'".$_."'";
22 s/\t/','/g;
23 s/\'\\N\'/NULL/g;
24 print "insert into $tablename values ($_);\n";
25 if ((++$linecount)== 1000)
27 print "commit;\n";
28 $linecount = 0;
31 close (INFILE);
34 print "commit;\n";