Sam Vilain wrote:
Adam Kennedy wrote:
Yes, native positional support is still important.
positions make it very easy to do SQL math.
To express it in overly simplistic code
$foo = [ "a = ?", "foo" ];
$bar = [ "b = ?", "bar" ];
$baz = "$foo and $bar";
# $baz now is [ "a = ? and b = ?", "foo", "bar" ];
Bearing mind a situation with an arbitrary number and complexity of
these sql fragments to be added together, doing this sort of thing
using named placeholders would be a nightmare.
Interesting. You are demonstrating reasons it is useful to deal with
SQL fragments in non-templated form.
In Tangram what you describe is written like this;
(SNIP)
Well, that was a simplistic example from which I had intended the
implication to be that it could be ANY two arbitrary pieces of sql. It
could just have easily been...
$foo = [
"ifelse(null(column), 0, DB2LOB.length(column)) > ? OR column5 is in
( ?, ?, ?, ? )",
100000, "alpha", "beta", "gamma", "delta"
];
$bar = [
"str2date(?, ?) between now() and str2date(?, ?)",
"20050401", "YYYYMMDD", "20040123", "YYYYMMDD"
];
$baz = [ "DB2XML.xpath_match(column3, ?)", "//foo" ];
my $where = join( 'and', $foo, $bar, $baz );
my $sql = DB->table->sql_select . 'where' . $where;
Who's to know what could be in the SQL fragments. We've all seen some of
the crazy and non-standard stuff various databases have.
(note: The SQL expressions were made up, but are of similar complexity
to known existing syntaxes)
Adam K