2 # Execute some SQL and display the result
4 require './custom-lib.pl';
5 if ($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/i) {
11 &error_setup($text{'srun_err'});
12 $cmd = &get_command($in{'id'}, $in{'idx'});
13 &can_run_command($cmd) || &error($text{'run_ecannot'});
17 $drh = DBI->install_driver($cmd->{'type'});
18 $drh || &error($text{'srun_edriver'});
19 ($driver) = grep { $_->{'driver'} eq $cmd->{'type'} } &list_dbi_drivers();
20 $dbh = $drh->connect($driver->{'dbparam'}."=".$cmd->{'db'}.
21 ($cmd->{'host'} ? ";host=$cmd->{'host'}" : ""),
22 $cmd->{'user'}, $cmd->{'pass'}, { });
23 $dbh || &error(&text('srun_econnect', $drh->errstr));
26 &ui_print_unbuffered_header(undef, $text{'srun_title'}, "");
27 print &text('srun_cmd', "<tt>$cmd->{'sql'}</tt>"),"<p>\n";
30 ($env, $export, $str, $displaystr, $args) = &set_parameter_envs($cmd, $cmd->{'sql'}, undef);
33 $cmd = $dbh->prepare($cmd->{'sql'});
35 print &text('srun_eprepare', $dbh->errstr),"<p>\n";
37 elsif (!$cmd->execute(@$args)) {
38 print &text('srun_eexecute', $dbh->errstr),"<p>\n";
42 if (@titles = @{$cmd->{'NAME'}}) {
43 print &ui_columns_start(\@titles);
46 while(my @r = $cmd->fetchrow()) {
47 print &ui_columns_row(\@r);
50 print &ui_columns_end();
55 print &text('srun_none', $r),"<p>\n";
59 &ui_print_footer("", $text{'index_return'});