Why are we going for cursor, can't we use procedure instead?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arumurali
    New Member
    • Mar 2013
    • 20

    Why are we going for cursor, can't we use procedure instead?

    Yes I know cursor is a private area where SQL commands are executed and we can use them for further use. Even the procedure is used to perform an action and it may or may not return a value. Also, i have heard that using cursor makes the process slow. Can anyone help me out on this?
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Usually you use cursor for fetching data from tables. When you create procedure and you want to get some data from table you also have to create cursor, you do it explicite or implicite.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Which one you use depends on the specifics of what you're trying to do. Since we have no specifics, there's no recommendations we can make.

      Comment

      • arumurali
        New Member
        • Mar 2013
        • 20

        #4
        Thanks for your response friends.

        @rski--> Again my doubt is can't we use procedure to fetch data from the table, is cursor a necessary one to go?

        Comment

        • rski
          Recognized Expert Contributor
          • Dec 2006
          • 700

          #5
          Even when you fetch data from table in procedure you use cursor ..
          For example if you write
          Code:
          for v in (select ....) loop
          ...
          end loop;
          oracle defines cursor.

          Comment

          • arumurali
            New Member
            • Mar 2013
            • 20

            #6
            So oracle defines cursor by default is what i got..Is that rite rski..?

            Comment

            • rski
              Recognized Expert Contributor
              • Dec 2006
              • 700

              #7
              You can define it explicite with CURSOR 'command' or implicite as I show in the example. In both oracle will create cursor

              Comment

              • arumurali
                New Member
                • Mar 2013
                • 20

                #8
                That was much helpful rski..

                Thanks for your time..!!

                Comment

                Working...