Special Character in Char column

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
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Special Character in Char column

Post by keshav0307 »

I have teradata table which has a column of type char(30), and in my job i have a transform just before inserting into this Teradata table. i am passing a value 'RSH_PROD_DTL' into this column, but when i query select * from <table_name> where <column_name>= 'RSH_PROD_DTL' ; it returns nothing and when i say select * from <table_name> where <column_name> Like 'RSH_PROD_DTL%' ; it returns the desired records. so i tthink there is some special charater inserted for rest of the space in column, can anyone suggest please how to handle this.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Your inserted value is of length 12. The column is defined as char(30), so the database adds spaces to honor the length of the column. Thats why you are not able to select without using the 'like' operand.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, Char fields are padded. The default pad character is set with an environment variable (APT_DEFAULT_STRING_PADCHAR if I remember correctly), but can be overridden down to the individual column level. Right click on the column in the Columns grid to open the editor and find the pad character property.

The default default value is \x00 (the ASCII "NUL" character). You can specify the space character as a space, as \040 (octal representation) or \x20 (hexadecimal representation).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

Thanks Ray. It worked
Post Reply