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
 

 

Regarding cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Regarding cursor
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Am sorry guys
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    Post subject:
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    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 Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


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