Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to extract from a VARCHAR COLUMN as character by SQL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
meetsupriyo

New User


Joined: 19 May 2009
Posts: 11
Location: Hyderabad

PostPosted: Sun Aug 04, 2013 8:33 pm    Post subject: How to extract from a VARCHAR COLUMN as character by SQL
Reply with quote

Hi,

I have a table on which a column is defined as VARCHAR(3500). I want to extract this column by SQL in a File. However as the column is VARCHAR, I am getting length as first two bytes which I dont want. Using CAST AS CHAR wont help as maximum character that I can extract is 255 I think. Is there anyway to extract the whole VARCHAR column as normal character without the length?

Thanks,
Supriyo.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Aug 05, 2013 2:31 am    Post subject:
Reply with quote

Hello,

One way would be to read the column into a ws-variable and then write your output file from this.
Back to top
View user's profile Send private message
meetsupriyo

New User


Joined: 19 May 2009
Posts: 11
Location: Hyderabad

PostPosted: Mon Aug 05, 2013 9:56 am    Post subject: Reply to: How to extract from a VARCHAR COLUMN as character
Reply with quote

Hi,

I dont want to write a COBOL DB2 Code for this. I was seeking if we can fulfil this requirement by a Job using SQL

Thanks,
Supriyo.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Mon Aug 05, 2013 12:41 pm    Post subject:
Reply with quote

Quote:
by a Job
of course you can do this - it just depends on what programs that job is trying to execute and if those programs can do what you need. If they cannot then you will have to write a piece of code that will do it. I would suspect that that would be the most efficient way of doing it - but maybe not.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Aug 05, 2013 2:02 pm    Post subject:
Reply with quote

Hi,

Do you the output file as FB?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Mon Aug 05, 2013 3:04 pm    Post subject:
Reply with quote

Supriyo,

Give a try on CLOB function,
Code:
select CLOB(columnname,3500)
from tablename

Not tested

Thanks,
Sushanth
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us