SQL::Library /

Filename Size Date modified Message
621 B
20.1 KB
76 B
428 B
3.1 KB
    SQL::Library - A module for managing simple SQL libraries stored in
    INI-like files.

    This document refers to version 0.0.5 of SQL::Library.

      use SQL::Library;
      my $sql = new SQL::Library { lib => 'sql.lib' };
                            # or { lib => [ <FH> ] };
                            # or { lib => [ $string ] };

      ## Ask for a library entry by name...
      my $query = $sql->retr( 'some_sql_query' );

      ## Add or update an entry...
      $sql->set( 'yet_another_query', <<'END' );
      SELECT foo
      FROM   bar
      WHERE  zoot = 1

      ## Remove an entry from the library...
      $sql->drop( 'one_more_query' );

      ## List the entries in the library...
      print join( ' : ', $sql->elements ), "\n";

      ## Dump the contents of the library to a string...
      my $lib_str = $sql->dump;

      ## Write the library to disk...

    The format for the library files looks a little like an INI file.
    However, unlike an INI file, it does not handle key=value pairs which
    are divided into sections. Library entry names are on a line by
    themselves, enclosed in square brackets. Whatever occurs until the next
    title tag is the value of the library entry. Blank lines, pound signs
    (#) and C++ style comments (//) are all discarded.

    A sample library file might look like this:

      ## A sample library file

      select   question_no,
      from     question
      where    survey_id = ?
      order by question_no

      select title,
             date_format( open_date, '%Y%m%d' ) as open_date, 
             date_format( close_date, '%Y%m%d' ) as close_date, 
      from   survey
      where  survey_id = ?

        Create a new library handle. Currently, the only argument supported
        in the hashref is "lib", which refers to the file containing the SQL

    $OBJ->retr( NAME )
        Returns the library entry referenced by NAME.

    $OBJ->set( NAME, VALUE )
        Sets the library entry NAME to VALUE. This is used both to create
        new library entries and to update existing ones.

    $OBJ->drop( NAME )
        Drops entry NAME form the library.

        Returns a list of all entry names in the library.

        Returns a string containing the library contents in the same INI
        format that the module reads from.

        Writes the library to the file named in "lib".

    *   write() should write to a string, if it was so called.

    *   Complete test suite

    Doug Gorley <douggorley@shaw.ca>

    Chris Vertonghen <chrisv@cpan.org> (post-0.0.3)

    Copyright (C) 2004 by Doug Gorley.

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself, either Perl version 5.8.2 or, at
    your option, any later version of Perl 5 you may have available.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.