John Cokos jcokos at ccs.net
Wed Aug 16 11:55:55 CDT 2000

Apologies, my finger slipped and I sent the mail before I finished it...

Just some thoughts on the CPAN module to be written ...

We kicked around a few ideas last evening, but never really
came to a final resolution on what the actual project will
be.  Seems like there were a lot of application ideas presented,
but not many actual usable module ideas.

So perhaps we could think of dividing our efforts into 2 parts
one: an appication, and two: a generic usable module.

My personal preference is a module.  My proposal is one
that I mentioned to a few people at Rock Bottom after the meeting:

a Wrapper for DBI.  I've gotten a good start on this, but it's
really a mess and needs TLC.  Anyone that's coded with DBD
can relate to it's shortcommings, and how much code it can take
to get simple things done.  The module I propose is a wrapper.

Current DBI Method:
    return("Some error") if($input{somevalue} !~ /someregexp/);
    .... and so on for each field.

    my $SQL = qq^
        UPDATE sometable SET
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
           somecolumn = '$input{somevalue}',
    $sth = $dbh->prepare($SQL);
    $rc = $sth->execute;

    if($DBI::errstr) { print "Failure .... \n"; }
    else { print "OK\n"; }

Proposed Module Method:
    my ($statuscode, $message) = $sql->isql_update_table( table=>'sometable', values=>\%input );
    print $message if( ! $statuscode );

Much less code, for the developer (especially considering that a typical SQL
aplication has many many different inserts and updates like that one throughout
the code), and a consistent back end that
would match the input to the table rows, do error checking, input validation,
etc.....and retun a meaningful error message.

Routines like that could be / should be written to handle selects statements
that give you the data as you want it instead of only one of the 3 ways DBD
allows for now, insert statements that do the extensive validations that the update
routine does, schema management, etc.


  John Cokos, President / CEO: iWeb Inc.
  jcokos at ccs.net

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For full traffic, use spug-list for LIST ; otherwise use spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list