Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Fetch for a cursor which has union query

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

New User


Joined: 20 Aug 2005
Posts: 5
Location: hyderabad

PostPosted: Thu Aug 25, 2005 10:17 am    Post subject: Fetch for a cursor which has union query
Reply with quote

Hi ALL,

I have declared a cursor which looks like

Declare c1 cursor for
select A1,A2,A3
.
.
unoin
Select A1 B2 A3
.
.
Here A1, A3 are from same tables and A2, B2 are from different tables.


Now i want to know during fetch how should i declare.

I declare has fetch
in to :A1,:A2,:A3,:A4
is it correct or please correct me

As it is uion for every fetch it will have only 3 columns.

Thanks
JR
Back to top
View user's profile Send private message

radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Thu Aug 25, 2005 11:09 am    Post subject:
Reply with quote

As it will return one record per fetch,
Fetch
into
:A1
:A2
:A3

is correct.the same is used in our shop.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Thu Aug 25, 2005 2:50 pm    Post subject:
Reply with quote

now i got you Q.

I think it can't be used like that even if A2 and B2 are of same data type.It will return only 3.
If A2 and B2 are of different data type then UNION itself cant be used.
Back to top
View user's profile Send private message
jayaramreddy.r

New User


Joined: 20 Aug 2005
Posts: 5
Location: hyderabad

PostPosted: Fri Aug 26, 2005 10:00 am    Post subject: Re: Fetch for a cursor which has union query
Reply with quote

jayaramreddy.r wrote:
jayaramreddy.r wrote:
Hi ALL,

I have declared a cursor which looks like

Declare c1 cursor for
select A1,A2,A3
.
.
unoin
Select A1 B2 A3
.
.
Here A1, A3 are from same tables and A2, B2 are from different tables.

Sorry

i declare has fetch into
:A1,:A2,:A3,:B2

at every fetch one record into

a1,a3 and b2 or a2

let me know

regards
Jr


Now i want to know during fetch how should i declare.

I declare has fetch
in to :A1,:A2,:A3,:A4
is it correct or please correct me

As it is uion for every fetch it will have only 3 columns.

Thanks
JR


Hi RK

Then please let me know how to declare fetch.

i declared as

Fetch
A1,A2,A3,B2

at time it will fetch A1,A3, and B2 or A2

i mean for every fetch there will three colums only and one colums will be spaces is it works
let me know

thanks
jayaram
Back to top
View user's profile Send private message
atik

New User


Joined: 29 Jul 2005
Posts: 20

PostPosted: Fri Aug 26, 2005 2:10 pm    Post subject:
Reply with quote

HI,
You are using Union means the column nos should be same. while fetching you are bothered about the number of columns not the table from which the data is coming. SO use 3 host variables.
Back to top
View user's profile Send private message
harinatha

New User


Joined: 24 Jul 2005
Posts: 28

PostPosted: Fri Aug 26, 2005 10:36 pm    Post subject: Re: Fetch for a cursor which has union query
Reply with quote

Hi,

I agree with atik. What he is saying is correct.

Thanks & Regards,
Hari.
Back to top
View user's profile Send private message
jayaramreddy.r

New User


Joined: 20 Aug 2005
Posts: 5
Location: hyderabad

PostPosted: Mon Aug 29, 2005 11:36 am    Post subject: Re: Fetch for a cursor which has union query
Reply with quote

harinatha wrote:
Hi,

I agree with atik. What he is saying is correct.

Thanks & Regards,
Hari.


But how can i differenciate A2 or B2 to write in to file

regards
jr
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

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