Help for this page

Select Code to Download


  1. or download this
     shell% cat concrete.sql 
     select city, date from weather where temp_lo < 20;
     shell% sql_test concrete.sql 
     shell% cat testexec.out # see results of prepare, execute on this
    
  2. or download this
     shell% cat abstract.sql
     select city, date from weather where temp_lo < ?;
     shell% sql_test abstract.sql 55 # send in placeholder value
     shell% cat testexec.out # to see results... looks good
    
  3. or download this
     shell% sql_register abstract.sql basic_weather
     [hi_and_low] inserted as 
     [select city from weather where temp_lo > ? and temp_hi > ? LIMIT 10]
    
  4. or download this
     ... then in a Perl program (e.g. test.pl in this distribution)
     my $dbh = SQL::Catalog->db_handle; # optional - get the handle as you
    + please
     my $sql = SQL::Catalog->lookup('hi_and_low');
     my $sth = $dbh->prepare($sql);
     $sth->execute(55);
    
  5. or download this
     my $rows = $sth->rows;
  6. or download this
     [city_date_via_temp_hi] saved as
     [select city, date from weather where temp_hi > ?]
    
  7. or download this
     my $dbh = SQL::Catalog->db_handle;
     my $SQL = SQL::Catalog->lookup('city_date_via_temp_hi') or die 'not f
    +ound';
     my $sth = $dbh->prepare($SQL, $cgi->param('degrees'));
      .... etc
    
  8. or download this
     CREATE TABLE sql_catalog (
        query varchar(65535) , # the actual query
        tables varchar(255) ,  # tables used
    ...
        cmd varchar(40) ,      # SELECT, INSERT, UPDATE, etc
        phold int4   # number of bind_values
     );
    
  9. or download this
     mydb=# select label,cmd,columns,tables,phold from sql_catalog;
          label     |  cmd   | columns                          | tables  
    +| phold 
     ---------------+--------+--------------------------------------------
    +-------
     weather_hi    | SELECT | weather.city,weather.date        | weather |
    +     1
     hi_and_low    | SELECT | weather.city                     | weather |
    +     2