Page 1 of 1

RIGHT/LEFT Justify

Posted: Wed Jul 11, 2007 2:50 am
by cosec
When I view the records in the database through datastage it seems all the fields are left justified...how could I left Justify non numeric fields and Right justify numeric fields....I used the FMT Function but I dont think I am doing it right ... Pls advice

Posted: Wed Jul 11, 2007 3:08 am
by ArndW
Do you mean with "view data" in the designer or from somewhere else? The FMT function will work from the command line, but has nothing to do with "view data", where the datatypes and widths play a role in how things are displayed.

Posted: Wed Jul 11, 2007 3:12 am
by cosec
Yes using the View Data both in the designer and the DB2 Client it shows as left justified.

Posted: Wed Jul 11, 2007 3:18 am
by ArndW
You threw me off with FMT reference, since that isn't applicable to "view data". You cannot right justify in that window, the only formatting DS really uses is the field width to presize the display width.

Posted: Wed Jul 11, 2007 11:09 am
by cosec
I want the fields to be stored in the database as right justified...how do i accomplish that throuhg datastage
ArndW wrote:You threw me off with FMT reference, since that isn't applicable to "view data". You cannot right justify in that window, the only formatting DS really uses is the field width to presize the display w ...

Posted: Wed Jul 11, 2007 11:27 am
by narasimha
cosec wrote:I want the fields to be stored in the database as right justified...how do i accomplish that throuhg datastage
You don't have to do anything special in Datastage. Check in your database using an appropriate tool to confirm.

Posted: Wed Jul 11, 2007 11:37 am
by DSguru2B
Think in terms of, "How would I do this outside DataStage?" Is it even possible. I say have a chat with your friendly neighbourhood DBA.

Posted: Wed Jul 11, 2007 11:52 am
by chulett
cosec wrote:I want the fields to be stored in the database as right justified...
Um... why? :?

One generally doesn't worry about 'justification' inside a database. Perhaps if we were talking about a flat file with specific requirements on string fields, but since we're not...

You need to do this or just want to do this? What field datatypes are we talking about here? Unless for some odd reason you've been given explicit requirements to right justify string fields, doing so could just screw up any process using that data that's not expecting it to be stored like that.

Posted: Wed Jul 11, 2007 7:23 pm
by ArndW
Numbers cannot be stored justified. If you want a string to be stored "right justified" then you need to explicitly pad the string with spaces on the left. Note that some datatypes such as VarChar2 will strip those leading spaces out of the string! Justification is never a data value issue, just a display method.

Craig - oops, I didn't notice your post until after I had submitted mine. Sorry for duplicating the content.