Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 19254
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: 2365
Location: Hampshire, 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: 1568
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: 1017
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 Foreign character look different in m... hsinaz50 COBOL Programming 3 Tue May 12, 2020 6:40 am
No new posts Need SQL for two latest records havin... Q5P418 DB2 10 Sun May 10, 2020 8:24 am
No new posts Issue while fetching a column(Nullabl... VINAY PALLELA DB2 18 Tue Mar 31, 2020 9:33 pm
No new posts To fetch value separated by commas fr... vinu78 DB2 3 Fri Feb 28, 2020 12:56 pm
No new posts To extract the records after the firs... saikarthik94 JCL & VSAM 5 Thu Feb 20, 2020 7:00 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us