Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Generic SQL query to convert text, clob to string
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 07/11/2011 :  06:19:28  Show Profile  Reply with Quote
Hi All,

I've declared a Hibernate column as type "text" which creates the column as "longtext" in MySQL, "nvarchar" in SQL Server and "CLOB" in Oracle.

I need to write a SQL query which works for all databases.

Ex: to_char() it doesn't works in MySQL but works fine in Oracle.

Please guide with a generic query which supports all the databases.


Most Valuable Yak

15732 Posts

Posted - 07/11/2011 :  07:43:12  Show Profile  Visit robvolk's Homepage  Reply with Quote
Look at the CAST() function, I believe that is ANSI standard and should work in all of the products you mentioned. Since each data type you mentioned is used for character data it should implicitly convert to a string in Hibernate.

If not you'll have better luck posting in a forum dedicated to Hibernate, SQLTeam is a Microsoft SQL Server site only.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000