Span for padding a substring must be non-negative: 0. No pad

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ArunaDas_Maharana
Participant
Posts: 42
Joined: Thu Dec 11, 2008 11:07 am

Span for padding a substring must be non-negative: 0. No pad

Post by ArunaDas_Maharana »

hi All,

I have a cloumn called state whose datatype[varchar] length[2]

i have following job:
Oracle enterprise>>>> transformer>>>sequential stage

in transformer i am padding the columns with spaces to create a fixed length record
something like
if IsNull(lnk_db_xfm.State) then PadString(""," ",2) else PadString(lnk_db_xfm.State," ",2-Len(lnk_db_xfm.State))

Other columns works fine but for above column i am getting warnings
Span for padding a substring must be non-negative: 0. No pad

I tried following:
1) checked the length of the state using length function it's 2
2) used if IsNull(lnk_db_xfm.State) then PadString(""," ",2) else PadString(lnk_db_xfm.State," ",0) to check whether v get warnings with ocurence length '0'-- result is no warnings.
3) i tried if IsNull(lnk_db_xfm.State) then PadString(""," ",2) else PadString(lnk_db_xfm.State," ",2-Len(trim(lnk_db_xfm.State))) i tried trim function before getting the length -- result no warnings

The output column is for state is also varchar[2]
Can anyone explain whats happening here!!
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Do you have NLS enabled ?

Introduce a peek stage and display the values of state with len(state).
ArunaDas_Maharana
Participant
Posts: 42
Joined: Thu Dec 11, 2008 11:07 am

Post by ArunaDas_Maharana »

NLS is not enabled.

I saw the data through peek state:CA length:2

Can anyone please provide some pointers to check whats happening here!

Thanks,
Aruna
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Why don't you just make your target column a char 2 and ensure your APT_STRING_PADCHAR is 0x20, that way you don't need to think about padding... although you may still have to worry about lengths > 2

A peek won't necessarily help if you have more rows than what you are peeking in to. In Oracle do a max(length(state))
ArunaDas_Maharana
Participant
Posts: 42
Joined: Thu Dec 11, 2008 11:07 am

Post by ArunaDas_Maharana »

thanks kryt0n i will go with your suggestion that makes more sence to me !
Post Reply