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

Regarding cursor


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
babuprasad_g
Currently Banned

New User


Joined: 26 May 2005
Posts: 45
Location: gurgaon

PostPosted: Fri Sep 02, 2005 2:19 pm
Reply with quote

Hi frends,

I have one problem.please help me in this regard.

I have one table like sortcode,branch_no,account_no,Customer_id,Customer_name,....
customer id unique.if it is a join account same customer id for both persons.not only 2 persons it is more than.
if the account is 3 persons join account the customer id is same for three persons.

we have one more file which is having the for each customer id how many accounts.

customer id ----- noof records
---------------------------------
10001 -------- 2
10002 -------- 3
. .
. .
. .
like that
main problem is we have to retrive the all records for each customer id.

i followed i declare the cursor for retriveing records with where condition.
where no of records = ws-a.
first read the file.
move the variable in to ws-a then fetch the records.

my problem is for each time am closing the cursor and fetching again and again.

am looking for one time with out closing the cursor again and again.
Did anybody face the problem ever please let me know.

My mail id is:babuprasad.gumpu@rbs.co.uk
Back to top
View user's profile Send private message
mainframesguru

New User


Joined: 24 Jun 2005
Posts: 36
Location: Hyderabad

PostPosted: Fri Sep 02, 2005 2:31 pm
Reply with quote

Hi,

I didn't read the whole question, but it needs refining.

Please improve your Presentation of Question and Vocabulary as well.

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

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Fri Sep 02, 2005 3:25 pm
Reply with quote

Hi Prasad,

I am very sorry to tell you that I am unable to understand your question. But as I understood you are having two problems one is with SQl Query and the second one is with CURSOR.

- Better to refine your query using Joins so that you can get the information what you want in one fetch.

- Still If you want to open and close the cursor then use WITH HOLD option while declaring the cursor.

- If u need help regarding WITH HOLD search the forum.

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

New User


Joined: 13 Jun 2005
Posts: 8
Location: hyderabad

PostPosted: Fri Sep 02, 2005 4:11 pm
Reply with quote

first of all to remain the cursor open use with hold
and coming to joint account part
instead of reading the file u declare and start fetching the records.......
this is for only 1 person having one account
but in case of joint account you please check about the customer id part
Back to top
View user's profile Send private message
babuprasad_g
Currently Banned

New User


Joined: 26 May 2005
Posts: 45
Location: gurgaon

PostPosted: Fri Sep 02, 2005 4:54 pm
Reply with quote

Hi,

First i have one sequential file with CUSTOMER-ID and NO-OF-ACCOUNTS

Second i have one table with some values like

SORT CODE,BRANCH NO,ACCOUNT NO,CUSTOMER ID...Some more columns.

Customer id unique but the table contains more than 1 records because it is the joint accounts.

i want to retrieve all records which is having joint accounts.

This is my question.
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Sep 05, 2005 3:54 pm
Reply with quote

Hi Bhanu,

I understood something now. But still I am confusing about your words like CUST_ID is UNIQUE but contains more than one row how???. I am giving a solution to find the details of the customers with two records (I mean with same Cust_Id) in the table.

SELECT * FROM CUST_DETAIL WHERE CUST_ID IN (SELECT CUST_ID FROM CUST_DETAIL GROUP BY CUST_ID HAVING COUNT(*)>1);

Hopes it will work. Please let me know if you need more help on this.

Thanks,
Reddy.
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 Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
No new posts Dynamic cursor name in Cobol program COBOL Programming 1
Search our Forums:

Back to Top