24 September, 2017

Casting Data Type in Oracle Database

CAST function 
The CAST function converts a value from one data type to another data type.

Syntax
CAST ( [ Expression | NULL | ? ] AS Datatype)

Note : CAST conversions among SQL-92 data types.
The flowing are SQL-92 data types
  1. BOOLEAN
  2. SMALLINT
  3. INTEGER
  4. BIGINT
  5. DECIMAL
  6. REAL
  7. DOUBLE
  8. FLOAT
  9. CHAR
  10. VARCHAR
  11. LONG VARCHAR
  12. CHAR
  13. VARCHAR
  14. LONG VARCHAR
  15. CLOB
  16. BLOB
  17. DATE
  18. TIME
  19. TIMESTAMP
  20. XML
Examples
SELECT CAST (SYSDATE AS VARCHAR2 (12)) DATE_TO_VARCHAR FROM DUAL;
SELECT CAST ('12' AS INTEGER)  STRING_TO_NUMBERIC FROM DUAL;
SELECT CAST (NULL AS VARCHAR2 (2)) NULL_TO_STRING FROM DUAL;

As CAST only convert among SQL-92 data types, we can not use for example RAW data type.
But there are some packages casts to RAW like utl_raw.cast_to_raw

SELECT UTL_RAW.CAST_TO_RAW('Mahmoud') FROM DUAL;
output is : "4D61686D6F7564"

9 comments:

  1. Excellent blog I visit this blog it's really awesome. The important thing is that in this blog content written clearly and understandable. The content of information is very informative.
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    Oracle Fusion Financials Online Training
    oracle fusion financials classroom training
    Workday HCM Online Training
    Oracle Fusion HCM Classroom Training

    ReplyDelete
  2. Such an amazing blog! Thanks for sharing this useful information... please keep posting.
    Web Development Company in Delhi

    ReplyDelete
  3. Nice Article..!
    Those who come to read your Information will find lots of helpful and informative tips.
    Website Development Company in Pune,Bangalore,Delhi
    Web Development Company in Pune,Bangalore,Delhi

    ReplyDelete
  4. Thanks for sharing information
    "Pressure Vessel Design Course is one of the courses offered by Sanjary Academy in Hyderabad. We have offer professional
    Engineering Course like Piping Design Course,QA / QC Course,document Controller course,pressure Vessel Design Course,
    Welding Inspector Course, Quality Management Course, #Safety officer course."
    Piping Design Course
    Piping Design Course in India­
    Piping Design Course in Hyderabad
    Welding Inspector Course
    Quality Management Course
    Quality Management Course in india
    Safety officer course

    ReplyDelete
  5. Excellent and decent post. I found this much informative, as to what I was exactly searching for. Thanks for such post and please keep it up.
    Weblife Infotech Pvt. Ltd.

    ReplyDelete
  6. I read your blog it is very good and you are doing a great job for helping others. I really appreciate what content you are giving to your viewers.
    Website Design Delhi

    ReplyDelete
  7. I really appreciate this post and I like this very much. I am waiting for new post here and Please keep it up in future.. Website Design Sydney

    ReplyDelete

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...