use strict; use DBI; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); $|++; print header (); print start_html; my $db_username="user"; my $db_password="password"; my $db_serverstring="DBI:Driver:here"; my $dbh = DBI->connect ($db_serverstring, $db_username, $db_password) +|| die ("Cannot connect to database -- DBI reports ", $DBI::errstr); print "\n"; if (param("view")) { h3"<CENTER>Viewing tables</CENTER>"; my @tables = param("view"); foreach (@tables) { my $sql = $dbh->prepare ("sp_columns $_") || die;; my $sth = $sql->execute or die "no ".$DBI::errstr; print h3("<CENTER>Viewing table $_</CENTER>"),"<TABLE Border = + 1>\n"; my $THdone; while (my $result_ref = $sql->fetchrow_hashref()){ unless ($THdone) { foreach (sort keys %$result_ref) { print "<TH>$_ </TH>"; } $THdone = "yes, indeedy!"; } print "<TR>"; foreach (sort keys %$result_ref) { if (! defined $$result_ref{$_}) {print "<TD><I>undef</ +i></TD>";next} print "<TD>$$result_ref{$_}</TD>"; } print "</TR>\n"; } print "</TABLE><BR><BR>"; } } else { print h2"<CENTER>Viewing sp_help</CENTER>"; print start_form; my $sql = $dbh->prepare ("sp_help") || die;; my $sth = $sql->execute or die "no ".$DBI::errstr; print "<TABLE Border = 1>\n<TH>Select me!</TH>"; my $THdone; while (my $result_ref = $sql->fetchrow_hashref()){ unless ($THdone) { foreach (sort keys %$result_ref) { print "<TH>$_ </TH>"; } $THdone = "yes, indeedy!"; } print "<TR><TD>",checkbox(-name=>"view",-checked=>"", -value=> +"$$result_ref{Name}"),"</TD>"; foreach (sort keys %$result_ref) { if (! defined $$result_ref{$_}) {print "<TD>--undef--</TD> +";next} print "<TD>$$result_ref{$_}</TD>"; } print "</TR>\n"; } print "</TABLE>"; print submit; print end_form; } print end_html;
In reply to SP_HELP_DUMP by boo_radley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |