Get size of LONG RAW data column in ORACLE - oracle

I'm new to Oracle. I want to get size of binary data store in LONG RAW column, I execute this query
SELECT LENGTH(BINARY_DATA) FROM MY_DATATABLE WHERE ID = 58;
But I get error
ORA-00932: inconsistent datatypes: expected NUMBER got LONG BINARY
What wrong with my Query?
Thanks.

The LENGTHB function is supported for single-byte LOBs only. It cannot be used with CLOB and NCLOB data in a multibyte character set.
LENGTH() expects CHAR as it's parameter.
Documentation:LENGTH

Related

How to Read/Convert Long RAW in Oracle

In an old application (no source code available) long texts with over 40.000 characters are stored in an Oracle database in a table column of type LONG RAW. We now want to transfer the texts into another Oracle database and want to display their content. Somehow the old application was capable to do so. However, we always run into a 4000 byte limit...
How can we export/import and display the content in a human readable VARCHAR2 (or multiple ones).
All convert functions we tried seam not to work. For example TO_LOB or TO_CLOB.
ORA-00932: Inconsistent datentype: - expected, LONG BINARY found
ORA-00932: Inconsistent datentype: CHAR expected, LONG BINARY found
From the documentation:
TO_LOB converts LONG or LONG RAW values in the column long_column to LOB values. You can apply this function only to a LONG or LONG RAW column, and only in the select list of a subquery in an INSERT statement.
So you can't do:
select to_lob(old_column) from old_table;
ORA-00932: Inconsistent datentype: - expected, LONG BINARY found
But you can move the data into a BLOB column in another table:
insert into new_table(new_column)
select to_lob(old_column) from old_table;
db<>fiddle
Once you have the data as a BLOB you can manage it as a binary value, or if it represents text then you can convert it to a CLOB - using the appropriate character set - with the dbms_lob package.

convert DB2 column with varbinary datatype to equivalent in oracle

I have column datatype on db2 as
"column name" VARBINARY(2000) defalut Binary(X'20')
I need its equivalent column datatype and default value for oracle
Use RAW or LONG RAW Datatype, However Oracle recommends BLOB and BFILE datatypes for large amounts of binary data.
Check this link for further information
Use Oracle type RAW or LONG RAW , and use the same default value.
Example:
,mycol raw(2000) default to_number(' ')
datatype replacement for VARBINARY is raw in oracle( as per remaining answers).
But the default value for Binary(X'20') is representing a space.
As the hexadecimal value for a space is 20,and for that reason its mentioned as X'20'.
select rawtohex(' ') from dual; which will give you 20.

Oracle CLOB retrieval of entire field

I need to retrieve a CLOB field from oracle db
I have no problems to retrieve first n charachters (using DBMS_LOB.SUBSTR in a query works with limit to 4000 chars), but don't work if I try to retrieve largest field containing unicode chars (kanji).
Is there a method to do so?

SQLPLUS displaying of tables with CLOB types

I have a table which has 3 columns. I have a NUMBER column, CLOB column, and BLOB column. how can i use some sort of SELECT * statement in order to display what I have entered into this table, not just a partial piece of the long character strings i have in there. The only way I know of displaying a long string form a CLOB would be using the DBMS_LOB.substr technique. My BLOB column is currently all NULL so not too worried about displaying that section, Just the number column with its associated CLOB. Thanks!
See here How to query a CLOB column in Oracle
When getting the substring of a CLOB column and using a query tool that has size/buffer restrictions
sometimes you would need to set the BUFFER to a larger size.
For example while using SQL Plus use the SET BUFFER 10000 to set it to 10000 as the default is 4000.
Running the DMBS_LOB.substr command you can also specify the amount of characters you want to return and the offset from which.
So using DMBS_LOB.substr(column, 3000) might restrict it to a small enough amount for the buffer.
See oracle documentation for more info on the substr command
DBMS_LOB.SUBSTR (
lob_loc IN CLOB CHARACTER SET ANY_CS,
amount IN INTEGER := 32767,
offset IN INTEGER := 1)
RETURN VARCHAR2 CHARACTER SET lob_loc%CHARSET;

SSIS Oracle Data Load is Incomplete

I have a data flow task where the data from oracle source is fetched and stored in SQL Server DB after nearly 400k rows the data flow fails with following error.
ORA-01489 result of string concatenation is too long
I the Execution results the [Oracle Source [1543]] Error: what this exactly means.
I'm assuming you are using varchar2 datatype which limits to 4000 chars.
This error is because the concatenated string returns more than 4000 chars of varchar2 which exceeds the limit try using CLOB datatype.
http://nimishgarg.blogspot.in/2012/06/ora-01489-result-of-string.html
use a derived column after your source to cut the strings to 4000 chars
Your data source (Oracle) is sending out strings that are larger than 4000 characters while your SSIS source expects something less than that. Check your source for any data that has a length > 4000.
After a long battle i decided to modify the package and it turns that deleting and creating the all the tasks again has solved the problem.
Real cause is still unknown to me.

Resources