SQL::Schema::View - A database view



NAME

SQL::Schema::View - A database view


SYNOPSIS

  my $view = SQL::Schema::View->new(%attr);
  my $sql = $view->create_statement;
  print $sql;
  print "$view";


DESCRIPTION

SQL::Schema::View is a class for objects representing a database view. The methods of an instanciated object do allow to access the information within a database's data dictionary and to represent them as SQL create statements and the like using the proper SQL dialect.

Constructors

  $view = SQL::Schema::View->new(%attr);

The new method instanciates a view object. The object is an in memory representation of a (possible) database view. The attributes are given as key value pairs by the hash %attr. Possible keys are:

  key              required?   value description
  view_name        yes         the name of the view (without a
                               preceeding schema name)
  aliases          no          a reference to a list of names
                               for the columns returned by the view
  subquery         yes         the SQL text of the subquery
  constraint_name  no          the name of the constraint for the
                               "with check option"; WARNING: The
                               subquery has to end with the text
                               'with check option ' to make this work
                               correctly
  $view = SQL::Schema::View->select($dbh,$name);

The select method fetches the attributes required by new from the database and returns the view object. (It calls new internally.)

If the view with the name $name could not be found within the database, the method returns undef.

The method's arguments are as follows:

$dbh
A database handle as defined by DBI(3).

$name
The name of the view without preceeding schema name.

Methods

The following attribute methods do return the current value of the attributes (as handed over to the new method):

  $name = $view->name;
  @aliases = $view->alisaes;
  $subquery = $view->subquery;
  $constraint_name = $view->constraint_name;
  $sql = $view->create_statement;
  $sql = "$view";

Returns a string containing an SQL statements for creation of this view. This method is overloaded with the string operator. So the two examples above are equivalent.

  $sql = $view->drop_statement;

Returns a string containing an SQL statement that would drop this view.


AUTHOR AND COPYRIGHT

  SQL::Schema::View is Copyright (C) 2000,
    Torsten Hentschel
    Windmuehlenweg 47
    44141 Dortmund
    Germany
    Email: todd@bayleys.ping.de
  All rights reserved.
  You may distribute this package under the terms of either the GNU
  General Public License or the Artistic License, as specified in the
  Perl README file.


SEE ALSO

DBI(3), the SQL::Schema(3) manpage,

 SQL::Schema::View - A database view