1 package SQL::Translator::Schema::View;
3 # ----------------------------------------------------------------------
4 # $Id: View.pm,v 1.1 2003-05-01 04:25:00 kycl4rk Exp $
5 # ----------------------------------------------------------------------
6 # Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; version 2.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 # -------------------------------------------------------------------
27 SQL::Translator::Schema::View - SQL::Translator view object
31 use SQL::Translator::Schema::View;
32 my $view = SQL::Translator::Schema::View->new(
34 sql => 'select * from foo',
39 C<SQL::Translator::Schema::View> is the view object.
48 use base 'Class::Base';
49 use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
53 # ----------------------------------------------------------------------
62 my $schema = SQL::Translator::Schema::View->new;
66 my ( $self, $config ) = @_;
67 $self->params( $config, qw[ name sql ] );
71 # ----------------------------------------------------------------------
78 Get or set the view's name.
80 my $name = $view->name('foo');
85 $self->{'name'} = shift if @_;
86 return $self->{'name'} || '';
89 # ----------------------------------------------------------------------
96 Get or set the view's SQL.
98 my $sql = $view->sql('select * from foo');
103 $self->{'sql'} = shift if @_;
104 return $self->{'sql'} || '';
107 # ----------------------------------------------------------------------
114 Determine whether the view is valid or not.
116 my $ok = $view->is_valid;
121 return 1 if $self->name && $self->sql;
126 # ----------------------------------------------------------------------
132 Ken Y. Clark E<lt>kclark@cpan.orgE<gt>