SQL::Schema::Trigger - A database trigger



NAME

SQL::Schema::Trigger - A database trigger


SYNOPSIS

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


DESCRIPTION

SQL::Schema::Trigger is a class for objects representing a database trigger. 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

  $trigger = SQL::Schema::Trigger->new(%attr);

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

  key               required?   value description
  trigger_name      yes         the name of the trigger (without a
                                preceeding schema name)
  description       yes         the "head" of the trigger's create statement
                                excluding `create trigger ' resp.
                                `create or replace trigger ' but including
                                everything from the trigger's name on up to
                                (but not including) the when_clause
  when_clause       no          the when clause of the trigger everything
                                from `when' until the start of the
                                PL/SQL block (remember: the PL/SQL block
                                starts with `declare' or `begin')
  trigger_body      yes         the PL/SQL block of the trigger including
                                `declare', `begin' and `end;'

All the keys correspond to the columns with the same name from Oracle's data dictionary view user_triggers.

  $trigger = SQL::Schema::Trigger->select($dbh,$name);

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

If the trigger 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 trigger 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 = $trigger->name;
  $description = $trigger->description;
  $when_clause = $trigger->when_clause;
  $trigger_body = $trigger->trigger_body;
  $sql = $trigger->create_statement;
  $sql = "$trigger";

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

  $sql = $trigger->drop_statement;

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


AUTHOR AND COPYRIGHT

  SQL::Schema::Trigger 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::Trigger - A database trigger