How to Truncate data in Oracle

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
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

How to Truncate data in Oracle

Post by ca.parker »

We have recently changed our database to 10g and now I am getting an error message:

extServiceRequest..Transformer_1: ORA-12899: value too large for column "SBLMART_DATA"."EXT_S_SRV_REQ"."DESC_TEXT" (actual: 302, maximum: 255)

Is there a function to trucate this data to a maximum length of 255? This is just a description field so we do not want this to be and longer than 255 and if it is then we just want to truncate the remaining data.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you already have a transform stage, just use "In.DESC_TEXT[1,255]" or "LEFT(In.DESC_TEXT,255)". If you have a modify stage you'll need different syntax, which I can't recall off the top of my head.

Or use the ORACLE "substr" DML command.
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

Post by ca.parker »

Here is what I currently have in the transformer:

OutputSRLink.DESC_TEXT[1,255]

I also tried left(OutputSRLink.DESC_TEXT,255) and still get the error message.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

first try to load only 200 characters and see what happens.

You might be getting double byte characters in source.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Do you have an NLS installation and how are your Oracle columns defined - by character or by byte?
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

Post by ca.parker »

Yes I am using the NLS map MS1252. I noticed the columns are defined as bytes also. Is there a way to define the columns as character instead?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure, it's an option when creating the column:

FRED1 VARCHAR2(20 CHAR)
FRED2 VARCHAR2(20 BYTE)
-craig

"You can never have too many knives" -- Logan Nine Fingers
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

Post by ca.parker »

Is this an option in Oracle or DataStage itself?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Oracle.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

Post by ca.parker »

Ok. So there is not any way I can just simple tell DataStage to truncate the data in the column is it exceeds 255?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You're already doing that with your substring notation of [1,255] - that limits it to 255 characters. Your problem is those 255 characters need more than 255 bytes to hold them. Any chance of getting the target table altered? All it takes is a simple MODIFY statement for the column in question and you can do it with the existing data there, i.e. the table does not have to be empty for this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ca.parker
Premium Member
Premium Member
Posts: 19
Joined: Fri May 16, 2008 6:10 am

Post by ca.parker »

Is there an option in DataStage for when the DDL is created to create that in character instead of byte?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'd have to switch to 'user-defined' DDL for that, I assume, and add the CHAR part yourself. Pretty sure the default when you don't specify either is BYTE.
-craig

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