Oracle Freakishness
"David E. Wheeler" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.dbi.general |
|---|---|
| Message-ID | <[email protected]> |
Fellow DBIers,
This query:
$dbh->selectrow_hashref(q{
SELECT c.change_id
, COLLECT(t.tag) AS tags
FROM changes c
LEFT JOIN tags t ON c.change_id = t.change_id
WHERE c.project = ?
GROUP BY c.change_id
}, undef, 'engine');
Generates this (useless) exception:
ORA-00932: inconsistent datatypes: expected - got - (DBD ERROR: error possibly near <*> indicator at char 51 in '
SELECT c.change_id
, <*>COLLECT(t.tag) AS tags
FROM changes c
LEFT JOIN tags t ON c.change_id = t.change_id
WHERE c.project = :p1
GROUP BY c.change_id
')
However, I can make the error go away by removing the use of placeholders. This version does not throw an error:
$dbh->selectrow_hashref(q{
SELECT c.change_id
, COLLECT(t.tag) AS tags
FROM changes c
LEFT JOIN tags t ON c.change_id = t.change_id
WHERE c.project = 'engine'
GROUP BY c.change_id
});
I can also eliminate the error by removing the COLLECT() line, but I really want an array there. Curiously, the error also goes away if I first execute without a placeholder and then with. IOW, this does not error out, either:
$dbh->selectrow_hashref(q{
SELECT c.change_id
, COLLECT(t.tag) AS tags
FROM changes c
LEFT JOIN tags t ON c.change_id = t.change_id
WHERE c.project = 'engine'
GROUP BY c.change_id
});
$dbh->selectrow_hashref(q{
SELECT c.change_id
, COLLECT(t.tag) AS tags
FROM changes c
LEFT JOIN tags t ON c.change_id = t.change_id
WHERE c.project = ?
GROUP BY c.change_id
}, undef, 'engine');
WTF Oracle?
Thanks,
David