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

Query in fetch delete .


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

New User


Joined: 21 Jun 2005
Posts: 69
Location: chennai

PostPosted: Tue May 26, 2009 2:08 pm
Reply with quote

hi,

I have a small query .

1. I am reading a table with cursor based on account number .So all the account numbers are been fetched in to temp memory
2. Now iam fetching the records one by one.
3. On some processing Iam deleting some next ten rows from the table.


4. On the next fetch which records will be retrived from the fetch, whether the records deleted or the 11th record from table.

please let me know asap
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue May 26, 2009 2:37 pm
Reply with quote

Quote:


On some processing Iam deleting some next ten rows from the table.


???

Whichever rows satisfied the cursor will still be available ....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 26, 2009 4:25 pm
Reply with quote

ramakrishnan

Quote:
I am reading a table with cursor based on account number

what exactly is the DEFINE CURSOR statement.

Quote:
So all the account numbers are been fetched in to temp memory


temp memory? are you trying to be technical? What do you mean by this?

Quote:
Now iam fetching the records one by one

that depends on the DEFINE CURSOR statement and the clauses of the FETCH statement.

Quote:
On some processing Iam deleting some next ten rows from the table.

which table? Do you issue a COMMIT anytime during this processing.

Quote:
On the next fetch which records will be retrived from the fetch, whether the records deleted or the 11th record from table.

that depends on the answers to the above questions.

Quote:
please let me know asap

you are kidding, right?
have you tried this yourself - not a very involved test program.
and you realize, the lack of information provided, precludes any answer other than Ashmir's?
You think we have nothing else to do except use our time for your technically unqualified theoretical BS?
Back to top
View user's profile Send private message
r2k1984

New User


Joined: 21 Jun 2005
Posts: 69
Location: chennai

PostPosted: Tue May 26, 2009 6:14 pm
Reply with quote

hey see Iam explaingin in detail.

I have declared a cursor to read all the records from the database whcih contains some 500 accounts.

on processing Iam deleting 100 with delete statement ,

Now I need to know whether it will be updated in the table and also in the cursor.

I dont want the accounts to come in the fetch statement and process the records .

Whether the problem will be solved after if I put a commit statement after the delete.

Or I should use the cursor with update option in the cursor definition.

Thanks in advance for the help
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue May 26, 2009 7:01 pm
Reply with quote

r2k1984,
Quote:
[ I should use the cursor with update option in the cursor definition.
....How would this help you in your current scenario.
Quote:
Whether the problem will be solved after if I put a commit statement after the delete.
Your processing should be logical, Open the cursor, fetch from the cursor, delete rows from the table and then issue a commit ....Again open the cursor and carry on similar lines as per your logic or requirement.

WTH
Back to top
View user's profile Send private message
r2k1984

New User


Joined: 21 Jun 2005
Posts: 69
Location: chennai

PostPosted: Tue May 26, 2009 7:33 pm
Reply with quote

I dont want to close the cursor and open it again because it will be overburden and it will go in loop if last record is deleted during the processing.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Tue May 26, 2009 7:45 pm
Reply with quote

Quote:
I dont want to close the cursor and open it again because it will be overburden
All the open cursors will close on commit until and unless you are using 'WITH HOLD' option....so you don’t go and explicitly close them.
Quote:
it will go in loop if last record is deleted during the processing.
There is nothing like first and last in the result set until you are not using order by in your query. Secondly, what makes you think it would go in a loop, use the SQL codes to determine your logic.

Do let us know your final results.

WTH
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue May 26, 2009 8:14 pm
Reply with quote

On what basis are you deleting the records ???... why dont you keep track of all records to be deleted ( values from cursor) and issue a single delete ????
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: Tue May 26, 2009 9:44 pm
Reply with quote

Hello,

Quote:
I dont want to close the cursor and open it again because it will be overburden
Where did this belief originate?

Quote:
it will go in loop if last record is deleted during the processing.
No, it won't if the code is written properly. FWIW - there is no "last record".
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 DELETE SPUFI DB2 1
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts How to delete a user's alias from the... JCL & VSAM 11
Search our Forums:

Back to Top