COnvert MS SQL to Oracle

I have a MS SQL statement that I need to have converted to Oracle.  I would do it myself except I don't have access to an Oracle environment to work in.

CAST([Event_Detail_Value] AS VARCHAR(256)) AS Event_Detail_Value2

Event_Detail_Value is a BLOB or CLOB in Oracle.

I only need the first 256  characters from it.  I assume if I need more it will just require changing 256 to 1000.

LVL 102
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnsoneSenior Oracle DBACommented:
I would use

SUBSTR("Event_Detail_Value", 1, 256) as Event_Detail_Value2

SUBSTR should work with a CLOB.

If it is a BLOB, taking the first 256 bytes doesn't make a whole lot of sense.  256 bytes of binary data typically isn't readable.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnsoneSenior Oracle DBACommented:
For a BLOB, I believe that SUBSTR will not work and you would have to use:

DBMS_LOB.SUBSTR("Event_Detail_Value", 256, 1) as Event_Detail_Value2

The DBMS_LOB call should work whether it is a CLOB or BLOB.
mlmccAuthor Commented:
Thanks.  I am not sure what it is right now.  The client is in the middle of an upgrade and right now it takes  special permissions to use the universe with the SQL.  Next chance I get, I will have them send the SQL as it is now.

PortletPaulEE Topic AdvisorCommented:
>>"...except I don't have access to an Oracle environment to work in."

there is a drop-down of rdbms types, Oracle 11g R2 is one of those
mlmccAuthor Commented:
The Substr worked.  The field is a CLOB.

The other suggestion would probably also work but we didn't try it.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.