#!/usr/bin/perl
# (c) 2000 Hans Mitloehner
use CGI;
$cgi=new CGI;
$user=$cgi->param('user');
$tabname=$cgi->param('tabname');
$colnames=$cgi->param('colnames');
@cols=split /,/,$colnames;
print "Content-type: text/plain\n
---------------------- Listenprozedur list$tabname.pl -------------------
#!/usr/bin/perl
use DBI;
require \"/usr/logins/usercgi/oracle_setup.pl\";
\$dbh = DBI->connect('DBI:Oracle:', '$user', '$user' );
\$sth = \$dbh->prepare(\"select $colnames from $tabname\");
\$sth->execute;\n";
$colnames=~s/^/,/;
$colnames=~s/,/,\\\$/g;
print "\$sth->bind_columns(undef$colnames);\n";
$colnames=~s/,\\/
/g;
print "print \"Content-type: text/html\\n\\n\\n\";
while (\@row=\$sth->fetchrow_array) { print \"$colnames\\n\"; }
print \" \\n\";
\$sth->finish;
\$dbh->disconnect;
";
print "---------------------- Erfassungsformular erf$tabname.html ----------------
$tabname Erfassen
\n";
print "---------------------- Erfassungsprozedur erf$tabname.pl --------------------
#!/usr/bin/perl
use DBI;
require \"/usr/logins/usercgi/oracle_setup.pl\";
use CGI;
\$gen_cgi=new CGI;\n";
for $c (@cols) { print "\$$c = \$gen_cgi->param('$c');\n"; }
print "\$gen_dbh = DBI->connect('DBI:Oracle:', '$user', '$user' );
\$gen_sth = \$gen_dbh->prepare(\$gen_q=\"insert into $tabname (";
for $c (@cols) { if ($flag) { print ","; } print "$c"; $flag=1; }
print ") values (";
for $c (@cols) { if ($flag2) { print ","; } print "\\'\$$c\\'"; $flag2=1; }
print ")\");
# In line above: REMOVE \\' around numeric fields!!
print \"Content-type: text/html\\n\\n\$gen_q \";\n";
print "if (!\$gen_sth->execute) { print (\"Error! \".\$gen_dbh->errstr); }
else { print \"OK.\"; }
\$sth->finish;
\$dbh->disconnect;
";
|