Wow! Thanks a lot!!! It is precisely what I was looking for!!!
I am working at a client that uses MS SqlServer and I was reluctant to use a windoze station to run "Query Analyzer" so I was determined to write my own if I had to!!!

For the curious here is the minimalistic version I was writing this morning before asking for wisdom here:

#!/usr/bin/perl use warnings; use strict; use DBI; use Term::ReadLine; use Switch; my $dbh = DBI->connect("dbi:Sybase:server=172.23.1.12;database=XXXXX" +,"YYYYY","ZZZZZZ") or die "$DBI::errstr\n"; my $term = new Term::ReadLine 'Simple DBI Shell'; my $prompt = "Enter your query: "; my $OUT = $term->OUT || \*STDOUT; print $OUT "Supports select statements only - type quit to exit cleanl +y!\n\n"; while ( defined ($_ = $term->readline($prompt)) ) { my $res = &doit($_); print $OUT $res, "\n" unless $@; $term->addhistory($_) if /\S/; } sub doit{ my $q = shift; $q =~ /^(\w+)/; switch(lc($1)){ case "select" {return &select_case($q)}; case "quit" {&byebye} else {return "ERROR: Only select statement and \'quit\' a +re allowed at this time"} } } # processes select statements sub select_case { my $q = shift; my $sth = $dbh->prepare($q); my $rv = $sth->execute(); #print put column names foreach (@{$sth->{NAME}}){ print $_."\t"; } print "\n"; #print out column values while (my @row = $sth->fetchrow_array){ foreach my $val (@row){ if (!defined($val)){ $val = 'NULL'; } print $val."\t"; } print "\n"; } $sth->finish(); } sub byebye { print $OUT "Have a nice day!\n"; $dbh->disconnect(); }

In reply to Re^2: CPAN SQL Monitor by ait
in thread CPAN SQL Monitor by ait

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.