Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Help a dummy out. Long Raw issue.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-07, 17:53
DBA-ONE DBA-ONE is offline
Registered User
 
Join Date: Dec 2002
Location: Sunny Florida
Posts: 113
Help a dummy out. Long Raw issue.

See below:

create table gg (xx long raw);

create table gg (x1 varchar2(4000), x2 varchar2(4000), x3 varchar2(4000), x4 varchar2(4000));

insert into gg select rpad('a', 4000, 'a'), rpad('b', 4000, 'b'), rpad('c', 4000, 'c'), rpad('D', 4000, 'D');

insert into g select x1 || x2 || x3 || x4 from gg;
*
ERROR at line 1:
ORA-01489: result of string concatenation is too long




SQL> select x1 || x2 from gg;
select x1 || x2 from gg
*
ERROR at line 1:
ORA-01489: result of string concatenation is too long


insert into g
select UTL_RAW.CAST_TO_RAW(x1 || x2) from GG
ERROR at line 1:
ORA-01489: result of string concatenation is too long

Up to now I've always made the programmers write info to these data types. I'm trying to write up to four 4000 character varchar values to a Long Raw. Am I doing something wrong or can this not be done the way I think it can?
Reply With Quote
  #2 (permalink)  
Old 05-14-07, 19:29
Indy_tomcat Indy_tomcat is offline
Registered User
 
Join Date: Nov 2006
Location: Indianapolis
Posts: 88
You should use Clobs instead of long raw

All of the ora-01489 errors are because in each case, you are trying to concatenate varchars (they are still varchars before you convert them)

Take a look at dbms_lob package
__________________
Nosce te ipsum…
Reply With Quote
  #3 (permalink)  
Old 05-15-07, 13:09
DBA-ONE DBA-ONE is offline
Registered User
 
Join Date: Dec 2002
Location: Sunny Florida
Posts: 113
I'll look in to that package.

If I try
insert into g
select UTL_RAW.CAST_TO_RAW(UTL_RAW.CAST_TO_RAW(x1) || UTL_RAW.CAST_TO_RAW(x2)) from GG;

I get

ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: raw variable length too long
ORA-06512: at line 1

Any clue?
Reply With Quote
  #4 (permalink)  
Old 05-15-07, 16:23
Indy_tomcat Indy_tomcat is offline
Registered User
 
Join Date: Nov 2006
Location: Indianapolis
Posts: 88
I'm just guessing that cast_to_raw is going to raw, and not long raw

Raw is limited to 2000
__________________
Nosce te ipsum…
Reply With Quote
  #5 (permalink)  
Old 05-15-07, 16:34
Indy_tomcat Indy_tomcat is offline
Registered User
 
Join Date: Nov 2006
Location: Indianapolis
Posts: 88
There's probably lots of ways to do this, this is one. It works because the concats at end are all CLOBs

PHP Code:
--Ora10r2create table gg (x1 varchar2(4000), x2 varchar2(4000), x3 varchar2(4000), x4 varchar2(4000));

Table created.

--
Ora10r2insert into gg select rpad('a'4000'a'), rpad('b'4000'b'), rpad('c'4000'c'), rpad('D'4000'D'from dual;

1 row created.

--
Ora10r2create table gg_clob (c1 clobc2 clobc3 clobc4 clob);

Table created.

--
Ora10r2insert into gg_clob (select from gg);

1 row created.

--
Ora10r2create table one_clob (bigclob clob);

Table created.

--
Ora10r2insert into one_clob (select c1 || c2 || c3 || c4 from gg_clob);

1 row created
__________________
Nosce te ipsum…
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On