Page 1 of 1

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

Posted: Thu Apr 22, 2010 3:30 am
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!!

Posted: Thu Apr 22, 2010 4:46 am
by Sainath.Srinivasan
Do you have NLS enabled ?

Introduce a peek stage and display the values of state with len(state).

Posted: Sun Apr 25, 2010 11:41 pm
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

Posted: Mon Apr 26, 2010 3:11 pm
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))

Posted: Tue Apr 27, 2010 3:01 am
by ArunaDas_Maharana
thanks kryt0n i will go with your suggestion that makes more sence to me !