Home » SQL & PL/SQL » SQL & PL/SQL » Meaning of cursor.delete (10g)
Meaning of cursor.delete [message #407632] Wed, 10 June 2009 21:42 Go to next message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
Hi,

I was going through an existing program, code structure is as below.

    CURSOR cur1
    IS 
      --some sql;


    TYPE curr IS TABLE OF cur1%ROWTYPE
        INDEX BY PLS_INTEGER;

    l_cur curr;

OPEN cur1;

    LOOP

        l_cur.DELETE(1, l_cur.COUNT);

        FETCH cur1 BULK COLLECT INTO l_cur LIMIT 300; 

        EXIT WHEN l_cur.COUNT = 0;

		for i in 1..cur1.count loop

  			-- process

		end loop;
     end loop;


close cur1;



Everything is clear, but im lacking understanding on the following statement

l_cur.DELETE(1, l_cur.COUNT);



Can anyone explain the meaning and what is the impact if this statement is not there?
Re: Meaning of cursor.delete [message #407635 is a reply to message #407632] Wed, 10 June 2009 22:54 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
It is not "cursor.delete". It is "collection.delete".
Check these links, link1 and link2.

Basically in your code, it is nullifying the l_cur variable, so that it can insert new records. But I don't think it is needed.

By
Vamsi
Re: Meaning of cursor.delete [message #407643 is a reply to message #407632] Wed, 10 June 2009 23:20 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Remove useless empty lines when you post to make your code shorter and easier to read.
There is no need to have an empty line between each line code.

Regards
Michel
Re: Meaning of cursor.delete [message #407676 is a reply to message #407643] Thu, 11 June 2009 01:16 Go to previous messageGo to next message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
Michel,
yes i will remove the empty lines in future post.


Thank you vamsi, but may i know why it is not needed and in which situation do we use this statement

[Updated on: Thu, 11 June 2009 01:18]

Report message to a moderator

Re: Meaning of cursor.delete [message #407682 is a reply to message #407676] Thu, 11 June 2009 01:36 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Quote:
FETCH cur1 BULK COLLECT INTO l_cur LIMIT 300;
After executing this statement anyway you will have new data in l_cur. No need to delete the previous data before the FETCH.

But this is not true for the normal FETCH without BULK COLLECT.

By
Vamsi
Re: Meaning of cursor.delete [message #407683 is a reply to message #407682] Thu, 11 June 2009 01:43 Go to previous message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
thank you vamsi, that clarifies my doubts.
Previous Topic: Converting Date
Next Topic: Using SYS tables as a normal user
Goto Forum:
  


Current Time: Sat Dec 10 03:25:45 CST 2016

Total time taken to generate the page: 0.09212 seconds