SQL::Preproc

SQL::Preproc is a Perl module to embed SQL in your Perl (ala SQL preprocessors).
Download

SQL::Preproc Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dean Arnold
  • Publisher web site:
  • http://search.cpan.org/~darnold/

SQL::Preproc Tags


SQL::Preproc Description

SQL::Preproc is a Perl module to embed SQL in your Perl (ala SQL preprocessors). SQL::Preproc is a Perl module to embed SQL in your Perl (ala SQL preprocessors).SYNOPSIS use SQL::Preproc subclass => 'Chart', emit => 1, keepsql => 1, syntax => , pponly => 1, relax => 1, alias => 1, debug => 1; use DBI; use DBI qw(:sql_types); use SQL::Preproc::ExceptContainer; use DBIx::Chart; ...some code... my ($host, $user, $passwd) = @ARGV; DECLARE CONTEXT $sqlpp_ctxt; CONNECT TO "Teradata:$host" USER $userid IDENTIFIED BY $passwd AS myconn WITH tdat_mode => ANSI; my $more_rows; WHENEVER NOTFOUND { $more_rows = undef } WHENEVER SQLERROR { my ($ctxt, $err, $state, $errmsg) = @_; die $errmsg; } DECLARE CURSOR mycursor AS SELECT * FROM mytable FOR UPDATE; OPEN mycursor; my ($col1, $col2, $col3, $col4); while ($more_rows) { FETCH mycursor INTO :$col1, :$col2, :$col3, :$col4; if ($col1 > $col4) { UPDATE mytable SET col4 = col4 + 100 WHERE CURRENT OF mycursor; } } CLOSE mycursor; # # do a bulkload via array binding # my @col1 = (); my @col2 = (); my @col3 = (); # # load some data into the arrays, then send it to the DBMS # EXEC SQL INSERT INTO sometable VALUES(:@col1, :@col2, :@col3); # # now create a chart, dumping results to @_ # SELECT * FROM mytable RETURNING LINEGRAPH(*), IMAGEMAP WHERE WIDTH=500 AND HEIGHT=500 AND FORMAT='PNG' AND LOGO='myimage.png' AND X_AXIS='Date' AND Y_AXIS='Stock Price' AND MAPNAME='stockmap' AND SIGNATURE='GOWI Systems, Inc.' AND SHOWPOINTS=1 AND POINT='opencircle'; open(OUTF, '>mychart.png') || die $!; binmode OUTF; print OUTF, $_; close OUTF; open(OUTF, '>mychart.map') || die $!; print OUTF, $_; close OUTF; DISCONNECT myconn;Requirements:· Perl 5.8+ (preferably 5.8.5+)· DBI 1.42· Filter::Simple 0.78· Text::Balanced 1.95· DBIx::Chart 0.01 (only when subclass => 'Chart')· DBI Driver for target database system Requirements: · Perl 5.8 (preferably 5.8.5 ) · DBI 1.42 · Filter::Simple 0.78 · Text::Balanced 1.95 · DBIx::Chart 0.01 (only when subclass => 'Chart') · DBI Driver for target database system


SQL::Preproc Related Software