CLOB dbms_lob.substr ORA-01461

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

CLOB dbms_lob.substr ORA-01461

Post by mavrick21 »

DSGurus,

After reading up on all the posts, related to this issue, I'm posting this new thread.

I've a job with Oracle DB table as source and target. The source table has a CLOB field with a maximum of 7600 chars. We want the job to typecast CLOB to Varchar, split them and populate it in two separate Varchar fields of 4000 length each.

In the source DRS stage I've all the source fields plus two Varchar(4000) fields (say TGTfield1 & TGTfield2) with derivation as below:

Code: Select all

NVL(CAST(dbms_lob.substr(CLOBfield, 4000,1) AS VARCHAR(4000)),'-')
NVL(CAST(dbms_lob.substr(CLOBfield, 4000, 4001) AS VARCHAR(4000)),'-')
I've a transformer between source & target DRS stage. I've tried with Varchar (4000 byte) & Varchar (4000 char) in target table but unless I specify the below derivations in transformers I get ORA-01461 error.

Code: Select all

Source_Load.TGTfield1[1:1999]
Source_Load.TGTfield2[1:1999]
I've also set the target DRS stage to UTF-8 which shows up in Loaded Maps Only.

Is this a DataStage issue (NLS?) or Oracle DBMS_LOB package issue?

Kindly advise. Thanks.
-Mav
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The fact there's an Oracle error code suggests that there's an Oracle issue. Did you try CAST .. AS VARCHAR2 instead of VARCHAR ?

That said, your substring syntax is incorrect; you need a comma rather than a colon. string[1,1999] returns the first 1999 characters from string. You could also specify Left(string,1999) which I think is more self-documenting.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Ray,

CAST .. AS VARCHAR2, CAST .. AS VARCHAR, string[1,xxxx] and Left(string, xxxx) work as long as xxxx value is 1999 and below. Any number above 1999 results in ORA-01461 error ( ORA-01461: can bind a LONG value only for insert into a LONG column)

I tried dbms_lob.substr on the source table and it splits the CLOB column at correct start & end positions. I need to implement this in DS job since source & target tables are on different Databases.

Thanks
-Mav
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That error implies that your substringed CLOB value is greater than 4000 bytes so guessing an NLS issue. Perhaps you can use Long Varchar as the intermediate value?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Craig,

LongVarchar(4000) for the 2 columns in source DRS stage and transformer, and Varchar(4000) in target DRS stage?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not sure... perhaps in all three, and you may need to bump the internal field size up as well. Play. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

But don't I have to stick with 4000 Chars/Bytes in the target DRS stage since Varchar2 supports only a maximum of 4000 Chars/Bytes?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No... setting it bigger just means DataStage will allow it to 'overflow' and get rejected by Oracle if anything turns out to not fit. And the limit is in bytes, not characters.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

I'll try it first thing tomorrow morning and update the post.

I don't have any/much knowledge about NLS like on which tiers (OS, DB, DS) it has to enabled, how to check if they are enabled or how to enable them. If you can please share some good links, PDFs and tutorials to enlighten me I would be very grateful.

Thanks Ray & Craig! I appreciate it very much.
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Craig,

I bumped up internal size for both fields in the DS job and ended up with ORA-01461 error in the target stage.

Could it be the NLS issue?
The source & target DB have the same NLS setting: select * from nls_database_parameters -- AL16UTF16. The dsenv file doesn't contain NLS_LANG or ORA_NLS environmental variables. Also just echoing them at the UNIX prompt returns blank result.

Now by just entering ORA_NLS=AL16UTF16 and NLS_LANG=AL16UTF16 in dsenv mean that all the settings are correct for the NLS data to flow through? Do I've to restart DS engine for any dsenv changes? Since NLS maps show up in DRS stage does it mean that NLS support was installed when DS was installed?

Thanks
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Also wanted to check - Should OS also be NLS enabled during its installation?

Thanks.
mavrick21
Premium Member
Premium Member
Posts: 335
Joined: Sun Apr 23, 2006 11:25 pm

Post by mavrick21 »

Found an alternate solution: split the source CLOB field to four varchar fields, each 1999 chars long, in the target.

Hope this info is useful to others.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I think Arnd posted a similar solution some time ago. Whatever works. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply