The original solution URL is: http://www.experts-exchang
Main Topics
Browse All TopicsI was to trying to use the solution provided by mszacik for convert long raw into varchar2 data type in oracle 8i. I am using it in Oracle 9i.
Mostly it works fine. In some cases I got the error in SQLPlus as:
ERROR at line 2:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "ABC.TEXTRAWIO", line 62
The line 62:
62 hex_data := rawtohex(raw_data);
63 rawlen := length(hex_data);
I think this may related to the varchar2 data limit? if so , how can I deal with it ?
Thank you for advice
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The original solution URL is: http://www.experts-exchang
I think that your problem is in this piece of code:
IS
raw_data LONG RAW;
rawlen NUMBER;
hex_data VARCHAR2(32760); --<<---------- Variable to small ? Try: hex_data CLOB
char_data VARCHAR2(32760);
loop_counter NUMBER;
BEGIN
-- Get the blob using the rowid passed in.
-- Will always retrun only one row.
SELECT ole_object_blob
INTO raw_data
FROM tidblob
WHERE v_object_id = rowid;
-- Convert the raw data to hex.
hex_data := rawtohex(raw_data);
rawlen := length(hex_data); --<<------ DBMS_LOB.GET_LENGTH instead
Thank you all for the inputs. I used the suggestions from paquicuba and slightwv , it works fine, but one things is that it's kind of slow. So we have a java stored procedure to do the similar thing, the problem is the
java String can't be converted to CLOB, any idea to deal with that?
public static String rawToText(String sql_query){
String result = "";
try {
Connection conn =
DriverManager.getConnectio
PreparedStatement pstmt = conn.prepareStatement(sql_
ResultSet rSet = pstmt.executeQuery();
//System.out.println("sele
byte[] ba = null;
while (rSet.next()){
// this should only go one time
ba = rSet.getBytes(1);
}
// copy the byte array into a StringBuffer
if (ba != null){
StringBuffer sb = new StringBuffer();
for (int i=0;i<ba.length;i++){
int c = ba[i];
sb.append((char)c);
}
result = sb.toString();
}else{
result = "";
}
}catch (Exception e){
e.printStackTrace();
result = "Exception: " + e.getMessage();
}
return result;
}
CREATE OR REPLACE FUNCTION rawToText (sql_query IN VARCHAR2) RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'IN_ReadRaw.rawToText(java
These code works fine within the VARCHAR2 limits, but has problem with larger size data. So I was trying to change the return value of the function from VARCHAR2 to CLOB, the compliler didn't complain, but when I try to use it , I got error saying :
SQL> /
ERROR:
ORA-00932: inconsistent datatypes: expected Unsupported conversion
no rows selected
Any help will be greatly appriciated!
I was trying to return CLOB as shown below:
CREATE OR REPLACE FUNCTION rawToText (sql_query IN VARCHAR2) RETURN CLOB
AS LANGUAGE JAVA
NAME 'IN_ReadRaw.rawToText(java
/
The compilation went OK. the query results the ORA-00932: inconsistent datatypes: expected Unsupported conversion.
Business Accounts
Answer for Membership
by: nav_kum_vPosted on 2007-01-04 at 09:04:09ID: 18244512
please paste your full code, so that someone can assist you.