Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    1

    Unanswered: How to use a cursor...????

    hello everyone i am new to using cursors and have been asked to research it myself for my own knowledge by tutor because they dont teach it us...and before someone thinks its for homework etc its not because we get solutions to questions by tutor anyway...it is a question from a beginners book to plsql and on cursors and wanted to gain the solution so i can examine it and apply it to another problem

    A description of the Employees and LEAST_EARNERS tables are shown below.

    Employees TABLE
    Name Null ? Type
    empno NOT NULL NUMBER(4)
    last_name VARCHAR2(10)
    job VARCHAR2(9)
    mgr NUMBER(4)
    hiredate
    salary
    DATE
    NUMBER(8)

    LEAST_EARNERS TABLE
    Name Null ? Type
    salary NUMBER(8)

    Create a PL/SQL block that determines the bottom n salaries of the
    employees within an organisation and inserts them into a table called
    LEAST_EARNERS. The block should prompt the user to accept a
    number n from the user where n represents the number of earners
    from the EMPLOYEES table. You should create a cursor called
    emp_cursor that retrieves the salaries of employees in ascending
    order. The salaries should not be duplicated. In the executable section,
    open the cursor and fetch the least n salaries and insert them into the
    LEAST_EARNERS table. Include any appropriate exceptions.

    thankyou for the help in advance

    even if someone can give me a start like what should i declare then i have a go would be great i have a little clue so far i have.....

    BEGIN
    FOR emp_cursor IN ( <your select statement goes here> )
    LOOP
    BEGIN
    <do stuff here>
    END;
    END LOOP;
    EXCEPTION
    <exception handlers go here>
    END;

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •