I have experience using MSSQL 2008 and I recently had to move from MSSQL to Oracle 10g.
The people who designed the (Oracle) table, which has a column I need to extract data from, used a BLOB
type column for the XML they need to store.
In MSSQL you would have simply stored your XML string in an XML
type or used a VARCHAR(MAX)
. Assume a table myTable
with a column called myColumn
which is a VARCHAR(MAX)
containing <ROOT><a>111</a></ROOT>
If you wanted to convert the VARCHAR(MAX)
type to an XML
type you would simply write something like:
SELECT CONVERT(XML, myColumn) FROM myTable
if you wanted, you could then use XQuery to get data from the converted column, like so:
SELECT CONVERT(XML, myColumn).query('/ROOT/a')
How would you accomplish the same thing in Oracle 10g if myColumn was a BLOB
, without having to write a stored procedure but still making it reusable? The text in the BLOB is UFT-8
.
I would really appreciate your assistance, as I kind of need this in a hurry.
sources :
For more character sets: http://www.mydul.net/charsets.html
You can convert from a BLOB to a CLOB and then pass the CLOB into the constructor of
XMLTYPE
. Here's a function...And for your specific example above you can use the
EXTRACT()
function:The above will return another XMLTYPE. If you want to get the text value of the node, you can use the
EXTRACTVALUE()
function instead.