Skip to Main Content
  • Questions
  • How to show special/unseen characters from a column in a plsql ?

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Derek.

Asked: March 20, 2019 - 8:41 pm UTC

Last updated: March 22, 2019 - 11:35 am UTC

Version: 12.1

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I have a table with special characters in a column. The column values are like this with the plsql
below.

set serveroutput on;
declare

c      varchar2 (100);
a      number;

begin
       for i in (     select ekd0756_current_value from prdusrvi.EKD0756 where record_id =2292 )
        loop
              for j in 1..length(i.ekd0756_current_value)
              loop
                     c      := substr(i.ekd0756_current_value,j,1);
                     a      := ascii (c);
                     dbms_output.put_line (j || '|' || c || '| ' || a);
              end loop;
              dbms_output.put_line ('----------------------------------');
       end loop;
end;
/


I can print all normal characters and special characters in decimal values, because I can't attached the result set, so I can't show the special character accii value. Is there a way I can upload the screenshot in Ask Tom which can clearly show my ideas? Above plsql can show unseen special characters in ascii values. But some special characters ascii value = 49819, is this correct?

Kind Regards,

Derek

and Chris said...

I'm not sure what you're asking here. The ASCII function

returns the decimal representation in the database character set of the first character of char.

So the character has the value 49,819 in your character set.

If you share the output of this and the DUMP function you can see the values stored in your column. Even if they are "invisible" or non-printable characters.

If you want to show inserts for these values, pass the value returned by ASCCI to CHR:

create table t (
  c1 varchar2(10)
);

insert into t values ( chr(49819) );
insert into t values ( chr(10) );

select c1, ascii ( c1 ), dump ( c1 ) from t;

C1   ASCII(C1)   DUMP(C1)               
?          49819 Typ=1 Len=2: 194,155   

             10 Typ=1 Len=1: 10   


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.