IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How do I right justify a string in an insert query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakesh17684

New User


Joined: 08 Oct 2006
Posts: 61
Location: San Diego

PostPosted: Wed Jun 08, 2016 8:01 pm
Reply with quote

Hi,

I want to insert large number of rows with one of fields going into a column defined with CHAR 30. I need the string inserted into the column to be right justified. How can it be done in an insert query ?

Thanks
Rakesh
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Jun 08, 2016 8:24 pm
Reply with quote

Why do you care how the data is stored in database? You need something on SELECT query to see it right justified only for YOU because then if someone don't want that way (now or in future) apart from you who uses that table then they will have to add additional function all the time when they references this field.
Try this.
Code:
 select lpad(strip('aaaaaaaaaaaaaaaaaaaa        '),30,' ') from sysibm.sysdummy1   
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top