Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Peculiar results from a simple looking query.
Turkbear wrote:
> "Mark C. Stock" <mcstockX_at_Xenquery .com> wrote: > >
> > > > Let's reexamine what CAST does in the context of a query: > > The Conversion requested by the CAST statement is in effect throughout the life of that query and applies to that affected > column however many times after the cast it is referenced. In effect you have created a virtual field named the same as the > original, uncasted, one and the query is accessing that virtual one - hence 2 characters long, like it was redefined. > > >
What is a CAST "statement" and is there any context other than a query when you would use it? (now I'm getting into that HJR "precise" mode... ;-) ) Here's what the documentation says for CAST and several dozen other conversion functions it is grouped with:
"Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists, WHERE clauses, START WITH and CONNECT BY clauses, and HAVING clauses. [...] Conversion functions convert a value from one datatype to another. [...] The SQL conversion functions are: [...] CAST [...]"
Nowhere is the totally unique and unexpected behavior of the CAST function mentioned, in the documentation or Metalink, so it is either a software bug or a very egregious, long-standing documentation bug.
I competely agree with mcs' comment. All the OP asked was whether or not anyone could explain or confirm what he saw, and whether there was a workaround (both of which have been accomplished by now). Somehow the presumed side issue of this being a problem when migrating from SQL Server (which *is* in fact documented in Metalink 210262.1) became the touchstone of this thread. That is not a problem, but the fact is there is something wrong with the behavior of CAST or the way it is documented, and nothing contributed so far has shown otherwise.
-Mark Bole Received on Fri Feb 25 2005 - 09:10:05 CST