[Copied to dbi-dev, but please reply to dbi-users]
Since the cat is out of the bag on upcoming SQL::Statement changes, here's a preview. Comments on the proposed syntax will be much appreciated.
The major additions will be column name aliases (thanks Robert Rothenberg), improved parsing (thanks Dean Arnold), and expanded support for functions including support for user-defined functions. Here's the syntax I am thinking of, please comment.
$dbh->do("CREATE FUNCTION foo");
# pre-declares function foo, a perl subroutine in current package$dbh->do("CREATE FUNCTION foo AS Bar::baz");
# pre-declares function foo, using baz, a subroutine in package Bar$dbh->do("LOAD Qux::Quimble");
# pre-declares all functions in package Qux::Quimble named SQL_FUNCTION_x
where x is all upper case letters or underscore
$dbh->do("DROP FUNCTION foo")
# unloads a function - e.g. if you want the parser to fail when it finds
a function not supported by your dialectFunctions, once loaded can be used almost anywhere that a value, column, or table can be used in SQL (assuming that the function returns the appropriate values(s) for its context). This means that functions can work as sub queries, predicates and procedures in addition to working as functions.
$sth = $dbh->prepare("SELECT MyFunc(args)");
$sth = $dbh->prepare("SELECT * FROM MyFunc(args) WHERE ...");
$sth = $dbh->prepare("SELECT * FROM TableZ WHERE MyFunc(args) AND ...");
$sth = $dbh->prepare("SELECT * FROM TableZ WHERE colX < MyFunc(args) AND ...");
-- Jeff
