Show
Ignore:
Timestamp:
04/16/08 09:53:38 (4 years ago)
Author:
kazuho
Message:

remove debug message, add READEME and POD

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Filter-SQL/trunk/lib/Filter/SQL.pm

    r9545 r9546  
    5757            $var =~ s/^{(.*)}$/$1/m; 
    5858            $out .= "' . Filter::SQL->quote($var) . '"; 
    59             print STDERR "Var - $out\n"; 
    6059        } 
    6160    } 
     
    104103 
    1051041; 
     105 
     106__END__ 
     107=head1 NAME 
     108 
     109Filter::SQL - embedded SQL for perl 
     110 
     111=head1 SYNOPSIS 
     112 
     113  use Filter::SQL; 
     114 
     115  Filter::SQL->dbh(DBI->connect('dbi:...')) or die DBI->errstr; 
     116 
     117  SQL CREATE TABLE t (v int not null);; 
     118 
     119  $v = 12345; 
     120  INSERT INTO t (v) VALUES ($v);; 
     121   
     122  foreach my $row (SELECT * FROM t;) { 
     123      print "v: $row[0]\n"; 
     124  } 
     125 
     126  if (SELECT ROW COUNT(*) FROM t; == 1) { 
     127      print "1 row in table\n"; 
     128  } 
     129 
     130=head1 SYNTAX 
     131 
     132Filter::SQL recognizes portion of source code starting from one of the keywords below as an SQL statement, terminated by a semicolon. 
     133 
     134  SQL 
     135  SELECT 
     136  SELECT ROW 
     137  EXEC SELECT 
     138  INSERT 
     139  UPDATE 
     140  DELETE 
     141  REPLACE 
     142 
     143=head2 "SQL" statement 
     144 
     145Executes following string as a SQL statement.  Returns an array of rows if executed statement is a SELECT statement, or returns result code if otherwise. 
     146 
     147  my @row = SQL SELECT * FROM t;; 
     148 
     149  SQL DROP TABLE t;; 
     150 
     151=head2 "SELECT" statement 
     152 
     153Executes a SQL SELECT statement.  Returns an array of rows. 
     154 
     155  my @row = SELECT * FROM t;; 
     156 
     157=head2 "SELECT ROW" statement 
     158 
     159Executes a SQL SELECT statement and returns the first row. 
     160 
     161  my @column_values = SELECT ROW * FROM t;; 
     162 
     163  my $sum = SELECT ROW SUM(v) FROM t;; 
     164 
     165=head2 "EXEC SELECT" statement 
     166 
     167Executes a SELECT statement and returns a DBI statement object. 
     168 
     169  my $sth = EXEC SELECT * FROM t;; 
     170  while (my @row = $sth->fetchrow_array) { 
     171      ... 
     172  } 
     173 
     174=head2 "INSERT" statement 
     175=head2 "UPDATE" statement 
     176=head2 "DELETE" statement 
     177=head2 "REPLACE" statement 
     178 
     179Executes a SQL statement and returns result code. 
     180 
     181=head2 VARIABLE SUBSTITUTION 
     182 
     183Within a SQL statement, scalar perl variables may be used.  They are automatically quoted and passed to the database engine. 
     184 
     185  my @rows = SELECT v FROM t WHERE v<$min_v;; 
     186 
     187  my @rows = SELECT v FROM t WHERE s LIKE "abc%$str";; 
     188 
     189A string between curly brackets it considered as a perl expression. 
     190 
     191  my $t = 'hello'; 
     192  print SELECT ROW {$t . ' world'};;   # hello world 
     193 
     194=head1 AUTHOR 
     195 
     196Kazuho Oku 
     197 
     198=head1 COPYRIGHT AND LICENSE 
     199 
     200Copyright (C) 2008 by Cybozu Labs, Inc. 
     201 
     202This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available. 
     203 
     204=cut 
     205