SQL::Query - Sql query generator for database entities.
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();
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' :
None.
Stores entity object that is wrapped by limit implementation.
Returns sql statement and bind variables array ref. Takes optionally array ref of the requested columns(undef return all columns in projection), condition object,
Change order_index for associated entity
Loads specyfic limit module wrapper.
SQL::Entity SQL::Entity::Column SQL::Entity::Condition
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.
Adrian Witas, adrian@webapp.strefa.pl
To install SQL::Entity, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Entity
CPAN shell
perl -MCPAN -e shell install SQL::Entity
For more information on module installation, please visit the detailed CPAN module installation guide.