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: 2567
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 Need Help with on of the coalesce query DB2 4
No new posts Can we Insert duplicates in Primary U... DB2 2
No new posts Need to split single line into two li... DFSORT/ICETOOL 7
No new posts insert into session tables with UR DB2 0
No new posts to Insert Rows from File1 to File 2 ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top