NAME

SQL::Tree - Generate a trigger-based SQL tree implementation

SYNOPSIS

use SQL::Tree qw/generate_sql_tree/;
use DBI;

my %opts = (
  dbtype    => $dbtype,
  drop      => $bool,
  table     => $table,
  pk        => $pk_column,
  pktype    => $pktype,
  parent    => $parent_column,
  path      => $path_column,
  path_from => $visual_column,
);

my $dbh = DBI->connect(...);
foreach my $sql ( generate_sql_tree( %opts ) ) {
  $dbh->do( $sql );
}

DESCRIPTION

SQL::Tree generates a herarchical data (tree) implementation for SQLite and PostgreSQL using triggers, as described here:

http://www.depesz.com/index.php/2008/04/11/my-take-on-trees-in-sql/

A single subroutine is exported (on demand) that returns a list of SQL statements:

  • generate_sql_tree( %opts ) -> @str

See the sqltree documentation for the list of arguments and their meanings.

SEE ALSO

sqltree(1) - command line access to SQL::Tree

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright 2010 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.