Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2002
    Posts
    6

    Question Unanswered: Oracle- Cast function

    In oracle, I want to convert varchar2 data into binary i.e. raw, but cating opertion is giving me error.
    Pl help.

    Pavan

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Oracle- Cast function

    Originally posted by pavangilda
    In oracle, I want to convert varchar2 data into binary i.e. raw, but cating opertion is giving me error.
    Pl help.

    Pavan
    You don't say what error you get.

  3. #3
    Join Date
    Dec 2002
    Posts
    6

    Re: Oracle- Cast function

    Originally posted by andrewst
    You don't say what error you get.
    name is varchar2 field

    select cast(name as raw(10)) from client ;

    After firing this query, i got the error
    ORA-01465: invalid hex number

  4. #4
    Join Date
    Dec 2002
    Posts
    11
    I suspect that name does not contain a valid hex number!

    I tried - select cast('1A' as raw(10)) from dual - which works fine - this says to me that the contents of the name field is not what you expect!

    Bob

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Oracle- Cast function

    Originally posted by pavangilda
    name is varchar2 field

    select cast(name as raw(10)) from client ;

    After firing this query, i got the error
    ORA-01465: invalid hex number
    You cannot cast just any text to RAW, it has to be text made up of hex digits, i.e. '0123456789ABCDEF':

    SQL> select cast( 'af' as raw(10)) from dual
    2 /

    CAST('AF'ASRAW(10))
    --------------------
    AF

    SQL> select cast( 'ag' as raw(10)) from dual
    2 /
    select cast( 'ag' as raw(10)) from dual
    *
    ERROR at line 1:
    ORA-01465: invalid hex number

  6. #6
    Join Date
    Dec 2002
    Posts
    6

    Re: Oracle- Cast function

    So what to i do to cnvert my text data into binary form.

    Originally posted by andrewst
    You cannot cast just any text to RAW, it has to be text made up of hex digits, i.e. '0123456789ABCDEF':

    SQL> select cast( 'af' as raw(10)) from dual
    2 /

    CAST('AF'ASRAW(10))
    --------------------
    AF

    SQL> select cast( 'ag' as raw(10)) from dual
    2 /
    select cast( 'ag' as raw(10)) from dual
    *
    ERROR at line 1:
    ORA-01465: invalid hex number

  7. #7
    Join Date
    Dec 2002
    Posts
    11
    Having thought about what you were doing, then read your last message... What you need is:-

    utl_raw.cast_to_raw('Varchar string in here')

    I use it to supply arguments in raw form for dbms_lob functions that have raw arguements.

    Bob

  8. #8
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Oracle- Cast function

    Originally posted by pavangilda
    So what to i do to cnvert my text data into binary form.
    I don't know. Why would you want to do that?

  9. #9
    Join Date
    Dec 2002
    Posts
    6
    So thanx Bob
    It work.
    Thanx
    Pavan

    Originally posted by Bob Gillett
    Having thought about what you were doing, then read your last message... What you need is:-

    utl_raw.cast_to_raw('Varchar string in here')

    I use it to supply arguments in raw form for dbms_lob functions that have raw arguements.

    Bob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •