简体   繁体   中英

convert raw text to_char in oracle dbeaver

How do i return below encoded result to char

SELECT  utl_encode.base64_encode(utl_raw.cast_to_raw('some_text')) COLM FROM DUAL;

I have tried

SELECT  TO_CHAR(utl_encode.base64_encode(utl_raw.cast_to_raw('some_text'))) COLM FROM DUAL;

-- I get error: SQL Error [932] [42000]: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

Reason why i need it in char/text is because i find it difficult to copy the result from dbeaver since dbeaver recognizes the result as an encrypted data hence encrypts it further or exports empty result.

Use UTL_RAW.CAST_TO_VARCHAR2 on the RAW value you've got:

SELECT  utl_raw.cast_to_varchar2(
          utl_encode.base64_encode(
            utl_raw.cast_to_raw('some_text')
          )
        ) COLM
FROM    DUAL;

outputs:

\n|  COLM |\n|  :----------- | \n|  c29tZV90ZXh0 | \n

db<>fiddle here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM