The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Query - Sql query generator for database entities.

SYNOPSIS

    my $entity = SQL::Entity->new(
        name                  => 'emp',
        unique_expression     => 'rowid',
        columns               => [
            sql_column(name => 'ename'),
            sql_column(name => 'empno'),
            sql_column(name => 'deptno')
        ],
        indexes => [
            sql_index(name => 'foo', columns => ['empno', hint => 'INDEX_ASC(emp FORCE_ORDER)'])
        ].
        order_index => 'foo',
    );

    my $query = SQL::Query->new(entity => $entity);
    my ($sql, $bind_variables) = $query->query();

DESCRIPTION

Generates sql for entity definition,

- navigation feature (limit/offset)

- ad hoc query optimialization (for where condition uses (subquerties or join dynamically))

Lets into account the following use cases:

    1, Retrieve employers with thier department:
    Physically it requries retrieving N rows starts from X row (offset/limit),
    so assuming that you have to fetch physically only 50 rows at the time
    from a few millions rows subquery will executes 50 times in the outer results.
    It may be faster the the join clause, especially when using single table CBO hint that
    is forcing result order rather then ORDER BY ...
    2, Retrieve employers with thier department for departaments 'hr','ho' :

EXPORT

None.

ATTRIBUTES

limit
offset
dialect
entity
_entity_limit_wrapper

Stores entity object that is wrapped by limit implementation.

METHODS

initialise
query

Returns sql statement and bind variables array ref. Takes optionally array ref of the requested columns(undef return all columns in projection), condition object,

set_sql_template_parameters
order_index

Change order_index for associated entity

load_module

Loads specyfic limit module wrapper.

SEE ALSO

SQL::Entity SQL::Entity::Column SQL::Entity::Condition

COPYRIGHT AND LICENSE

The SQL::Query module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl