Why we use the cursor

Hi all

I would be grateful someone right me if I'm wrong. I ask the question below just for my purpose of learning.

Question - Why do we use the cursor?

Response Cursor is used to treat several lines in PL/SQL.

Or

Is used to treat a set of records from one or more tables, you can write a cursor on the table using select statement and then you can browse through all these a Recordset, and perform your required operations.

Post edited by: Muzz, I'll open another discussion to my other question. Thank you

Hello

Muzz says:

Hi all

I would be grateful someone right me if I'm wrong. I ask the question below just for my purpose of learning.

Question - When we use Procedure and Function when?

Response

When you want to run a series of DML statements then do like us and when we want to return a single value, then we use the function.

Much has been written on this subject.  Start by finding some of them:

https://www.Google.com/#q=when+use+procedure+function+Oracle

read some of them and then ask a more specific question

Procedures are not just for the DML; There are a lot of things in addition to DML you can do in the procedures.  For example, you can send e-mail messages, or can read and write files.

The second half of your response, 'when we want to return a single value, then we use the function', is the right of bascally.  In particular, when you want to return a value that will be used in a SQL statement, you use a function.

Functions in the pipeline are a special case.  A lot of what you read or you say about 'functions' means implicitly 'no Pipeline functions.

Question - Why do we use the cursor?

Response Cursor is used to treat several lines in PL/SQL.

Or

Is used to treat a set of records from one or more tables, you can write a cursor on the table using select statement and then you can browse through all these a Recordset, and perform your required operations.

You'll have best results if you start a separate thread for each separate issue.  This issue is completely separate from the question on procedures

You're right that the sliders are a way to process the rowsets, which can contain 1 line or several lines.

Yes, you can use a slider to manage the rows one at a time.  Do not forget that it will be less effective than the manipulation of all at once, so don't use a cursor to do something that can be done in a single SQL statement.

Tags: Database

Similar Questions

  • Why doesn't the cursor disappears whenever I use it to move the window (Windows: 32.0 FF)?

    Why doesn't the cursor disappears whenever I use it to move the window (Windows: 32.0 FF)? How to bring back the cursor?

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe
  • why I use the new cc photoshop cannot open, have and pdf

    why I use the new cc photoshop cannot open have and pdf.

    and more slow then former execution

    According to your records, you bought the CC for photography program under the same ID from Adobe Photoshop.

    It gives you access to use Photoshop & light room.

    Concerning

    Stéphane

  • When to use the cursor for loop and the cursor (open, fetch, close)

    Hello world
    I have a small doubt about when to use the cursor for loop and when to use the cursor for loop and the cursor (open, fetch, close).
    Well, I'm not the difference between implicit and explicit cursor. So please tell me how I got to know, what to use and when?




    Kind regards
    BS2012

    Published by: BS2012 on January 29, 2013 12:15

    All SQLs are analyzed, stored and executed as cursors. Thus, you will always use a cursor.

    The problem is that languages, such as PL/SQL, provide different interfaces to interact with the SQL cursor. As the ref, the slider interface, the interface DBMS_SQL slider interface and so on.

    Each of these interfaces offers different features. For example, using the interface DBMS_SQL allows binding dynamics and dynamic recovery. The Ref Cursor interface allows your code PL/SQL pass a handle to a reference pointing to the SQL cursor, to an external client. Etc.

    The fundamental reason for the use of an explicit cursor interface is mainly that you own and manage bulk made extraction output provided by PL/SQL cursor.

    With a cursor FOR , the motor loop of PL/SQL optimize the loop by extracting block a 100 lines both. However, you cannot access this collection in bulk directly inside the loop.

    With an explicit cursor interface, you specify the size of the extraction in bulk via the clause LIMIT , and you set the variable of collection to use. This allows you to use the collection directly variable inside the loop.

    However, the need to do - code manually in bulk collection - rarely occur in the daily programs in PL/SQL. A line of treatment is both slow and not well fits. And even if your bulk code collects lines, these lines must still be processed one at a time in your code. It is much more efficient and scalable rather write SQL code, and make the engine SQL the line of treatment for you.

  • why we use the symbol $ java variable?

    his_$ account_tota, $ b... can u give an explanation for this variable. What is the symbol of $ use? Why we use the symbol $ java variable...
    I need a clear and simple explanation for example...: P

    No real reason, you can do it if you want. But you don't have to - I certainly didn't, and I rarely see code it does.

    You should take the time to find a way to find information. For example, I just typed 'java variable dollar' in google and ended up with this as the first shot:

    http://docs.Oracle.com/javase/tutorial/Java/nutsandbolts/variables.html

    I quote:

    "In addition, the character dollar sign, by convention, is never used at all."

  • Why not use the static methods - example

    Hello world

    I would like to continue the below thread about "why not use static methods.
    Why not use the static methods
    with the concrete example.

    In my small application, I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
    
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
              }
         }
         
         public static void wait(int millis){
              r.delay(millis);
         }
         
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         }
    
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
         }
    
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }
    You think it's a good solution? How could it be improved? I saw something Singleton vs somewhere of static methods. Wouldn't be better to use Singleton?

    Thanks for your comments in advance.
    lemonboston

    maheshguruswamy wrote:

    lemonboston wrote:

    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor, and provide a getInstance method to provide late initialization.

    Maheshguruswamy thanks for the tips on the steps create a singleton of this class.
    Perhaps you could say also why do you say that it would be preferable to use singleton? What is behind it? Thank you!

    In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. If a singleton should be sufficient.

    But who doesn't answer why he expected prefer a singleton instead of a bunch of static methods. Functionally, the two are almost identical. In both cases, there is that a single 'thing' to call methods - either a single instance of the class or the class itself.

    To answer the question, the main reason to use a Singleton on a class of static methods is the same reason readers much of not static vs static decisions: polymorphism.

    If you use a Singleton (and and interface), you can do something like this:

    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();
    

    And then everything calling public methods of KBI has to know that there an implementor of this interface, without worrying about what concrete class is, and you can replace some implementation is appropriate in a given context. If you do not need to do, then the approach of the static method is probably enough.

    There are other reasons that may suggest a Singleton - serialization, persistence, use as a JavaBean pop to mind - but they are less frequent and less convincing in my experience.

    And finally, if this thing keeps updated a State between method calls, even if you can manage it with static member variables, it is more in line with the OO paradigm to make them non-static fields of an instance of this class.

  • Update of a column by using the cursor

    Hello world
    always play with the stuff of newbie here. Is it possible to update a column or row with a slider? I understand how to extract data using a slider, but don't know if it helps to update the data.

    If it is possible, what is the syntax?

    Kind regards
    Valerie

    Valerie Debonair wrote:
    Hello world
    always play with the stuff of newbie here. Is it possible to update a column or row with a slider? I understand how to extract data using a slider, but don't know if it helps to update the data.

    Why not read the fine manual? [Oracle® PL/SQL Database User Guide and reference | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i40107] describes all the constructions of cursor.

    If it is possible, what is the syntax?

    The best way is to use a PL/SQL implicit cursor, as follows:

    declare
      empID number;
    begin
      empID := 1234;
    
      update emp
        set salary = salary +100
      where empno = empID;
    
      commit;
    end;
    
  • Why FF uses the IE temporary Internet files directory?

    I used Firefox exclusively as my browser for the last 6 months. Recently, I checked my "Temporary Internet Files" folder, where IE stores the pages visited and found complete and up-to-date, even if I had deleted everything that it when I started using FF. Why Firefox stores data here? Please note: on my computer, I have implemented the 'Temporary Internet Files' as folder hidden IE... IT IS NOT THE FF CACHE FOLDER. Thanks for any help.

    If you visit a Web site that uses MS plugins like Windows Media Player or Silverlight then these plugins will use the cache (temporary Internet files) Windows than IE also uses.

  • HP laptop, 2000 - 2a20CA: Page of the screen shrinks by using the cursor key

    Laptop HP 2000-2a20CA

    No. B5R61UA

    It seems the upgrade from Win 7 to win 10 Home edition, in navigation or by using a Microsoft Office program, the windows Explorer.

    When you move the cursor with the touchpad and then listen to select a link, function etc. anywhere on the screen/page.

    The screen will decrease in size to the left or right of the screen or reduce to the taskbar.

    Clues, there is problem Win 10 or touchpad.

    HP 2000-2a20CA, running Windows 10 laptop

    Thank you

    I think I solved the problem because now I think.

    To check the HP site looking for updates to Win 10 and none were found.

    But then I changed my version of Windows to win 8 then rechecked updates and there is an update for the touchpad dated March 2016.

    Downloaded and installed, and everything seems OK so far.

    Thanks again.

  • Point display XY graph using the cursor data

    Hello all, I use XY graph to display amplitude v/s time. During the vi execution, data are continuously plooted on chart until the user stops the vi. I want to add a feature, such that, during the execution of the vi, when the user clicks on the chart to the situation with the cursor, it should show corresponding value of time and amplitude of this point. I mean the value of the axis corresponding to the category axis not the cursor position. When you use the position of the cursor, it is ok with the x axis, but it shows the cursor position for y axis (as property said), and I want datavalue said not not the position y axis.

    I hope it's clear with the question. I would like to have a few examples... for y = x graphic below, you can see cursor x = 4.4 and y = 6.8, how to view corresponding datapoint which must be y = 4.4

    When creating (or even after you've created), choose "align on the" plot 0.

    Do not let it be 'slide free.

    Attached example.

  • why we use the network module

    Why use the network module? What is the purpose of it

    Hello

    When you buy a switch or router, it comes with some default interfaces and some empty slots.

    The default interfaces are usually ethernet interfaces; However, router or switch supports more types of interfaces. You can order and buy these interfaces according to your needs. New interfaces in the form of modules can be put inside these empty slots. Suppose you need a WAN connection between two places. If you buy a module WAN. It's like buying a card your computer's ethernet. Or you need to connect fiber optic cables to your router, you will need to purchase a module with a fiber interface.

    There are two types of module and also two different locations on the routers. Small slits are WIC and bigger for NM (network module)

    Module 1-network (your question).

    This is a great module which can contain a variaty of ports and also some NM modules and some WICs. These modules can usually be inserted into larger routers.

    2-

    WIC is smallest card that can be inserted into a router dirrectly or some cards NM.

    WIC and NM are a little old and today HWIC and NME are mainly used.

    Please click the link below to check the different types of module for router 2800. Take a look at modules with the prefix of NM, NME, WIC HWIC.

    http://www.Cisco.com/c/en/us/products/routers/2800-Series-integrated-SER...

    It will be useful,

    Masoud

  • Why we use the Cisco Voice environment CUBE

    Hi all

    Hope you all are doing well.

    (1) can someone describer that's why we use CUBE in Cisco voice environment and this is the main purpose? Configure the steps?

    (2) what is allowed and what type of license that we use in the world of VOICE?

    (3) features and integration between the CUCM CUPS CUPS?

    Thank you

    Arjun keita

    This very open Q

    To read a bit of paper on the product

    http://www.Cisco.com/c/en/us/products/unified-communications/unified-BOR...

    and no further questions, see the Q & A

    https://supportforums.Cisco.com/document/69976/frequently-asked-question...

    BR
    Mamdouh

  • Using the cursor to insert a value

    Hello
    I created a procedure mentioned below, using the slider that I want to insert a value in the table its not to insert any value. You can one to find the solution. I have compiled the procedure there is no errors...

    I have a lot of value in the employee... then after table do not perform the procedures no value in employee_lkp


    My structure from the Employee table is

    CREATE TABLE 'VIDHYA '. "' EMPLOYEE '.
    (
    VARCHAR2 (15 BYTE) "PNOM."
    'MINIT' VARCHAR2 (2 BYTE),
    VARCHAR2 (15 BYTE) "LNAME",.
    ACTIVATE THE "SSN" NUMBER (12.0) NOT NULL,
    "BDATE" DATE,
    'ADDRESS' VARCHAR2 (35 BYTE),
    'SEX' VARCHAR2 (1 BYTE),
    ACTIVATE THE "WAGES" NUMBER (7,0) NOT NULL,
    NUMBER (12.0) "SUPERSSN."
    ACTIVATE THE 'DNO' NUMBER (2.0) NOT NULL,
    ACTIVATE THE STATISTICS STORAGE CALCULATION (INITIAL 65536 THEN 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 USER_TABLES DEFAULT TABLESPACE) 'USERS' CONSTRAINT 'PK_EMPLOYEE' KEY PRIMARY ("SSN") WITH THE HELP OF INDEX PCTFREE 10 INITRANS MAXTRANS 255 2.
    CONSTRAINT 'FK_DEPARTMENT' FOREIGN KEY ('DNO') REFERENCES 'VIDHYA '. "" DEPARTMENT "("DNUMBER") ALLOW
    )


    employee_lkp structure is

    CREATE TABLE 'VIDHYA '. "" EMPLOYEE_LKP ".
    (
    VARCHAR2 (250 BYTE) "PNOM."
    VARCHAR2 (250 BYTE) "LNAME",.
    'ID '.
    )


    create or replace
    procedure employeelkp is
    number of add_val;
    i the number;
    number num.
    add_name cursor is select * from employee;
    name_cur add_name % rowtype;
    Start
    Open add_name;
    Select count (*) in the number of the employee;
    because me in 1.num
    loop
    extract the add_name in name_cur;
    insert into employee_lkp (id, fname, lname)
    values (i,
    name_cur. Lname,
    name_cur.fname);
    When the output add_name % notfound;
    end loop;
    close add_name;
    end employeelkp;

    Try this...
    Add

    commit;
    

    After

    close add_name;

    at the bottom.

    I hope this helps...

    Hamid

  • need to use the cursor for the query

    Hi all
    can someone tell me how to get the result of the following query using the slider?

    SELECT (SUBSTR('        ', 1,LEVEL*2)
      || t1.label) AS t1_label,
      amount
    FROM
      (SELECT t1.label,
        t1.ID,
        t1.parent_id,
        SUM(t2.turnover) AS amount
      FROM t1,
        t2
      WHERE t2.t1_id = t1.id
      AND t2.t1_id  IN
        (SELECT id
        FROM t1
          START WITH t1.ID       = 2
          CONNECT BY PRIOR t1.ID = t1.parent_id
        )
      GROUP BY t1.label, t1.ID, t1.parent_id
      ) t1
      START WITH t1.ID       = 2
      CONNECT BY PRIOR t1.ID = t1.parent_id;
    .. .and the result:
    t1_label             amount
    ---------------------------------------------------------
         B11     11778.54
          B121     19980.28
            B1211     18842.77
            B1212     25480.56
          B122     18339.07
        B12            23455.9
        B13            20876.52
    Thank you
    Alex

    Published by: 860003 on June 9, 2011 01:30

    Published by: 860003 on June 9, 2011 01:31

    Published by: 860003 on June 9, 2011 01:31

    decalare
    V_T1_lable varachar2 (250);
    Number V_AMT;
    cursor c1 is SELECT (SUBSTR (' ', 1, LEVEL * 2))
    || T1. Label) AS t1_label,
    amount
    Of
    (SELECT t1.label,
    T1.ID,
    T1.parent_id,
    Amount of Sum (T2.turnover) AS
    FROM t1
    T2
    WHERE t2.t1_id = t1.id
    AND IN t2.t1_id
    (SELECT id
    FROM t1
    START WITH t1.ID = 2
    CONNECT BY PRIOR t1.ID = t1.parent_id
    )
    GROUP BY t1.label, t1.ID, t1.parent_id
    ) t1
    START WITH t1.ID = 2
    CONNECT BY PRIOR t1.ID = t1.parent_id;

    Start
    Open c1;
    loop
    Fetch c1 into V_T1_lable, V_AMT;
    dbms_output.put_line(V_T1_lable||) e ---'|| V_AMT);
    When Exit C1% notfound

    end loop;
    exception
    When people then
    dbms_output.put_line(SQLCODE||) e --'|| SQLERRM);
    end;

  • How to choose the maximum value in a column of a table by using the cursor and iteration

    Hello everyone
    I have a table loan_detail
    and a column inside loan_amount
    now I want to take the values in this table with the cursor, then using iteration that I want to take a max value of him using this slider
    Here is my table
    LOAN_AMOUNT
    
    100
    200
    300
    400
    500
    5600
    700
    I could make using the concepts of single loop, but when I tried to do by using the slider I wasn't able to do.
    Concerning
    Prost

    You can get the maximum value for a particular column in SQL, PLSQL needn't; Always avoid PLSQL so you can do it in SQL. But always as an example:

    declare
    number of Temp: = 0;
    Start
    for news in some loan_amt of loan_detail
    loop
    If (temp
    end if;
    end loop;
    dbms_output.put_line (temp);
    end;

    Edited by: Mahanam January 5, 2011 03:11

Maybe you are looking for