I'm using Oracle 11g and I'm trying to find out the length of a text. I normally use select length(myvar) from table
, but I can't do that.
The table which I want to query has a BLOB
column that saves characters or photos. I want to know the number of characters that my BLOB
column has.
I tried to convert my BLOB
into a char using UTL_RAW.CAST_TO_VARCHAR2(myblob) from table
, but this functions isn't working correctly or maybe I'm making a mistake.
For example:
My BLOB
have the word Section
, when I see this in the databse in the hexadecimal form I see S.e.c.t.i.o.n.
. I don't know why it have those points in between each letter.
Then I used the this query:
select UTL_RAW.CAST_TO_VARCHAR2(myblob)
from table
The result of this query is 'S'
so it's not the complete word that my BLOB
has, and when I make this query:
select length(UTL_RAW.CAST_TO_VARCHAR2(myblob))
from table
the result is 18
, but the word Sections
doesn't have 18 characters.
I was trying to convert the BLOB
into a VARCHAR
, although I think my best choise would be a CLOB
because the length of the text that it can save is more than the limit that VARCHAR
has. I tried to do that by making this query (I'm not sure if this is correct but is what I found in the internet):
select UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(myblob, 32767, 1))
from table
This query also returns 'S'