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

How to extract from a VARCHAR COLUMN as character by SQL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Mon Aug 05, 2013 2:31 am
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Aug 05, 2013 12:41 pm
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

Global Moderator


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

PostPosted: Mon Aug 05, 2013 2:02 pm
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: 1020
Location: India

PostPosted: Mon Aug 05, 2013 3:04 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top