Please explain this part of the code

CREATE OR REPLACE PROCEDURE IS abc123
-Statements
v_T_MAP_record T_MAP_map % ROWTYPE;

TYPE t_element_cursor IS REF CURSOR;
v_T_MAP_cursor t_element_cursor;

number of v_T_MAP_count;
BEGIN
DBMS_OUTPUT. ENABLE (1000000);
v_T_MAP_cursor: = get_T_MAPs (1308); -This will get the record of the cursor

-Open the cursor
EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;

V_T_MAP_cursor % FOUND LOOP

dbms_output.put_line ('uc.use_case_id: ' | v_T_MAP_record.use_case_id);


v_T_MAP_count: = v_T_MAP_count + 1;

EXTRACTION v_T_MAP_cursor
IN v_T_MAP_record;

END LOOP;

-Close the cursor
CLOSE V_T_MAP_cursor;

EXCEPTION
While OTHERS THEN
dbms_output.put_line ('Error' |) TO_CHAR (SQLCODE) | ': ' || SQLERRM);
END;

I do not understand why we are having 2 game instruction Fetch IN v_T_MAP_record's first before the while loop v_T_MAP_cursor and the other inside the v_T_MAP_cursor. Please explain. If I remove the second instruction fetch inside the loop, it gives me a buffer overflow error.

It's what he does...

CREATE OR REPLACE PROCEDURE abc123  IS
    --Variable declarations
    v_T_MAP_record T_MAP_map%ROWTYPE;

    TYPE t_element_cursor IS REF CURSOR;
    v_T_MAP_cursor t_element_cursor;

    v_T_MAP_count number;
  BEGIN
    DBMS_OUTPUT.ENABLE(1000000);  -- THIS ISN'T REALLY NEEDED

    -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself)
    v_T_MAP_cursor := get_T_MAPs(1308);

    -- This fetches the first record from the cursor
    FETCH v_T_MAP_cursor
      INTO v_T_MAP_record;

    -- If a record is found we enter a loop
    WHILE v_T_MAP_cursor%FOUND LOOP
      -- output the current record details
      dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id);
      v_T_MAP_count := v_T_MAP_count + 1;

      -- fetch the next record
      FETCH v_T_MAP_cursor
        INTO v_T_MAP_record;
      -- loop back to the start of the while loop
    END LOOP;

    --Close the cursor
    CLOSE v_T_MAP_cursor;

  -- Pointless stupid exception handler
  EXCEPTION
    when OTHERS THEN
      dbms_output.put_line('Error ' || TO_CHAR(SQLCODE) || ': ' || SQLERRM);
  END;

Although this would be a better style:

CREATE OR REPLACE PROCEDURE abc123  IS
  --Variable declarations
  v_T_MAP_record T_MAP_map%ROWTYPE;
  TYPE t_element_cursor IS REF CURSOR;
  v_T_MAP_cursor t_element_cursor;
  v_T_MAP_count number;
BEGIN
  -- This opens the ref cursor, it doesn't fetch anything (assuming get_T_MAPs doesn't fetch itself)
  v_T_MAP_cursor := get_T_MAPs(1308);

  LOOP
    -- This fetches the first/next record from the cursor
    FETCH v_T_MAP_cursor INTO v_T_MAP_record;
    EXIT WHEN v_T_MAP_cursor%NOTFOUND;

    dbms_output.put_line('uc.use_case_id: '||v_T_MAP_record.use_case_id);
    v_T_MAP_count := v_T_MAP_count + 1;
  END LOOP;

  --Close the cursor
  CLOSE v_T_MAP_cursor;
END;

However, I would also change things to use the SYS_REFCURSOR as the need to define your own type from the REF CURSOR was placed back in 9i with the new type built in SYS_REFCURSOR.
There are probably many other things I would like examine why I'm using ref Cursor in the first place and why I try to write data using dbms_output etc., but hey, we all have start somewhere.

Published by: BluShadow on 28-Sep-2012 14:28

Tags: Database

Similar Questions

  • First run the part of the code

    Hi people,

    I'm using Labview to control a camera and a motor, who need a boot before I can use them.  Currently I have the status of fact manually, but there is a lot of time and unproductive.  I wish this part of my code to run first and before any other code in my VI.  I am a little naïve in the way that this is possible and my gutfeeling is it is should not be difficult.

    I tried to use boolean to start my loop once the code is executed, but it is not effective when I have more of a lead-in to run.  LabVIEW run them in parallel...

    If anyone can help?

    Thanks in advance.

    All you have to do is create a dependency on the data. Everything is in the stream!

    Can you give a little more detail on what your initialization code needs to do? Most likely, it generates an error at the end, so if if wire you this error at the edge of the main code loop, until the initialization is complete.

    A better solution would be to create a correct state machine, which is one of the States initialization code. The trigger as the first State. This method has the advantage that you can reset again at a later date if necessary, without the need for a restart of the program.

    Never trap code in a structure of sequence as shown above, it is very rigid. For example, it is not possible to pass from one State or change the running order.

  • Cannot download updates to silverlight, can not cancel this part of the old C:\temp\ext18866\ program what can I do?

    Cannot download updates to silverlight, can not cancel this part of the old C:\temp\ext18866\ program what can I do?

    Please post here for assistance: http://forums.silverlight.net/forums/13.aspx ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • I know little or nothing of WININET, but it seems that this may be the problem based on the error messages 9 out of 10 say involve this part of the Microsoft software.

    I'm not tech guru when it comes to computers.  I don't really know enough to get into trouble.  Here's my problem.

    For the last six weeks or so, I keep getting dropped offline.  AOL is my browser and I get the message "your AOL software has encountered a problem" or words to that effect.  Tech AOL were useless to solve the problem.  I checked my error messages and noticed that when I fell off line, most of them involved a WININET problem.  I know little or nothing of WININET, but it seems that this may be the problem based on the error messages 9 out of 10 say involve this part of the Microsoft software.  It's just a guess on my part, but the problem becomes very irritating to say the least.  So, if someone can you please throw some light on my problem it will be greatly appreciated? This WININET error message might have nothing to do at all with hit his offline, but thought I'd ask at least satisfy my limited knowledge of computer programs.

    Thank you

    Gordon

    Gordon

    To see if your system or software from AOL, what happens if you connect to AOL by using another browser (like Firefox or IE)?

    Wininit is part of the operating system and usually if it was the problem you would have other problems on your computer then I suspect it's an AOL software

  • Can someone please explain to me why the Metro of Windows 8 for the WSJ application contains all THE STORIES?

    Can someone please explain to me why the Metro of Windows 8 for the WSJ application contains all THE STORIES?   I have the WSJ app on my Kindle Fire and he has indeed all the stories that are included in hard print.   And why the hell not the app allows for offline reading?

    Also, why hell isn't there a WSJ application for windows phone 8?   I know there is a WSJ direct application that shows videos, but I want a real WSJ app that shows all items.

    Original title: Wall Street Journal APP

    You would be better served if you asked these questions WSJ that they control if an application exists and is happy.  Hope this helps and if you need another post to help and we will be happy to help you.

    The above opinion is mine and mine nothing and does not necessarily reflect that of Microsoft, it's employees, or any other Member of this forum

    "When we try to take anything by itself, we find it hitched to everything else in the universe."-John Muir

  • When clicked on a menu item is still done scroll to this part of the page but not properly noted in the menu more

    Today I opened my site in Muse to do some small updates and my head was completely broken, I have a header menu that uses the anchor points, and when clicked on a menu item is still made this part of the page-scroll but not correctly highlights the menu more.

    I also had a slideshow put in place to change each px 1100 scrolls, but who has stopped working completely.

    How did this happen without changing me anything? or I could go back to an old backup?

    It turns out all I had to do was reboot all and everything was fine, the program must just acted buggy

  • How to start the Audit Vault (Please run this command at the Vault review officer)

    Hi all.
    I just finished to complete a facility audit Vault on a dev linux system and all processes were available.

    In any case I had to restart my linux machine, but no process started automatically :(

    I'm reading how to start 'something'... by the use of the (e13841.pdf) Administrator's Guide...
    but without results...
    I don't know (I want to say I still have not found in the doc) sequences correct to start and stop services... when start the database... If there is a command to automatically audit Vault start the database...

    I tried...
    [oracle@auditvault ~] $ avctl show_oc4j_status
    AVCTL began
    Please run this command at the verification officer Vault.
    Leaving the control Audit Vault
    [oracle@auditvault ~] $ avctl start_oc4j
    AVCTL began
    Please run this command at the verification officer Vault.
    Leaving the control Audit Vault

    Thanks for your help

    Here are some actions you need to perform:

    Audit Vault Server you installed in your machine in ORACLE_HOME1
    You have installed Audit Vault Agent in your machine in ORACLE_HOME2

    1 / your database from ORACLE_HOME1

    export ORACLE_SID = yoursid
    sqlplus / as sysdba<>
    startup
    output
    EXPRESSIONS OF FOLKLORE

    2 / the AV from ORACLE_HOME1 Server

    avctl start_av

    3 / the agent runtime from ORACLE_HOME2 AV

    avctl start_oc4j

    4 / your agent from ORACLE_HOME1

    avctl start_agent - nom_agent

    At this point, you should be able to start any collector that you created previously. Be in command line mode, ORACLE_HOME1, or through the web console...

    Yves

    Published by: yves77 on May 14, 2009 19:21

  • Please explain this issue

    Hello

    I'm prerparing to SCJP.

    I got this question

    What will be the result of the program?

    {public}
    public static throwit Sub)
    {
    System.out.Print ("throwit");
    throw new RuntimeException();
    }
    Public Shared Sub main (String [] args)
    {
    Try
    {
    System.out.Print ("hello");
    throwit();
    }
    catch (Exception)
    {
    System.out.Print ("taken");
    }
    Finally
    {
    System.out.Print ("finally");
    }
    System.out.println ("after");
    }
    }

    A.

    Hello throwit caught

    B.

    Compilation failure

    C.

    Hello throwit RuntimeException captured after

    D.

    Hello throwit finally after

    What is treatment and why. Please explain

    answer would be D.

    car-

    The method main() correctly handles the RuntimeException in the catch block catch finally runs (as it always does), and then the code returns to normal.

    A, B, and C are incorrect based on the logic of the program described above. Don't forget that properly handled exceptions do not cause the program to stop execution.

  • Please explain this query

    Hi all

    Select col1, col2, col3, col4, col5, col6, count (*), grouping_id (col1, col2), grouping_id(col3,col4), grouping_id (col5, col6) of the Group FLAT_FILE_TEST of grouping sets (col3, col4), ((col1,col2) (col5, col6));

    Separate Grouping_id here is 0 and 3

    0 is for the current group, other grouping_id become 3.

    Someone please explain meaning of 3

    Why returning 3?


    Thank you

    Elayaperumal S

    Hello

    Thanks for posting the sample data.   I get errors on all directions of INSERTION, because the column names aren't the names of columns in the CREATE TABLE statement.

    Don't forget to post the results you want from these data, as well as an explanation of how you can (not necessarily how Oracle will be) the results of these data.

    Maybe you have nothing particular in mind; you're just experimenting GROUPING_ID to see how it works.

    In this case, if I have not answered your question in my first answer, so I understand not what is your question.

    In general terms,.

    GROUPING_ID (x_n,... x_2, x_1, x_0) equals

    (GROUPING (x_n) * POWER (2, n)) +.

    ...

    (GROUPING (x_2) * POWER (2, 2)) +.

    (GROUPING (x_1) * POWER (2, 1)) +.

    (GROUPING (x_0) * POWER (2, 0))

    If you have any questions, please tell what it is.  For example "on lines where gro1 = 7, why is - this 7 and not 4?  Instead of theis... in language SQL manual it says... and you said... so I expect gro1 to 4 because... «,.

    GROUPING_ID is so intimately linked to the GROUPING, then, in your result set, include GROUPING (x), where x is any column that you use as an agrument to GROUPING_ID, for ease of understanding.

  • Please explain why I get the message 'Error while Uploading an attachment' error

    Attempt to attach a PDF file to an outgoing email and I get the above message. The file is a readable pdf and may be a play on my computer but not attached to the email.

    Firefox send an e-mail, it's strictly a web browser.

    If you use Firefox to access your e-mail, you use "webmail". You must seek assistance from your service provider or a forum for this service.

    If your problem is with Mozilla Thunderbird, please Tag this thread as being for Thunderbird in the right column of this page. This issue is currently in the queue of Firefox to get answers.

  • delay time in a part of the code.

    Hello

    I am developing an application using Labview version 9. the application is to acquire a shock wave Flash of a scope of 2012B of tektronix on a PC and generate a report with parameters waveform as the rise time, queue time and the crest of the wave.

    I was able to acquire the wave and generate with all the settings.

    However when I built an exe program and ran it on a laptop it has a time limit for the generation of reports (about 3-4 minutes) bring up the menu for the generation of reports. And also I find not very friendly code. Please guide me so that I can optimize the code for a faster exit.

    Suggestions and information to improve my code would be useful.

    Thanks in advance...

    Use the computer of State Architecture.

    Avoid using multiple loops when it is unnecessary

    You can exit the loop using the structure of the event in the state machine rather than handling separate loop to kill Apllication labVIEW which is not advised.

    You do not require a separate loop updated indicator of Globals.

    http://search.NI.com/nisearch/app/main/p/bot/no/AP/tech/lang/en/PG/1/SN/catnav:Tu/q/State%20machine/

  • Windows Advanced personal care V2... this part of the operating system?

    I have something called Advanced Windows Care V2 Personal on my computer and want to know if this is part of the program, or if it is something that has been downloaded later. I remember not seen before and I just had a call from someone said his name was Alan Gray Windows service dept in Toronto, and her phone number is 915-581-1797. I told her that I had to check with the RCMP, and he hung up. I'm hetting many of these calls and I don't know if they put this thing care windows on my computer or if it was already on here.

    Advanced Windows Care V2 only not part of Windows. It is a product of IObit http://www.iobit.com/ . V2 is obsolete and may be obtained for free from download sites.

    You allowed anyone who called you to access your computer?

    Unsolicited phone calls claiming that there are problems reported since your computer are all scams.

    http://www.Microsoft.com/en-GB/security/online-privacy/avoid-phone-scams.aspx

  • Writing to a file that is packaged in the deployed application (part of the COD file)

    Hello

    Thanks RexDoug, I got the link that shows how to read a config/prefs file included in the application code that I'm deployment.

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

    However one thing, I realized that I also need to write to this file, so my question is: is it possible to also write to a file included in the deployed application? If so, any tips/sample code would be greatly appreciated.

    Kind regards

    Sean.

    Similar question on writing a file on SD card in this thread:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&thread.ID=55847

    I would use the name/value pair in PersistentStore approach to do this, which saves the duty serialize into a stream of bytes output to write the file.

  • Please explain this code

    I take the test and found this code-

    public class Outer
    {

       public void someOuterMethod()
      {
       //Line 5
      }
       public class Inner { }
      
       public static void main(String[] argv)
      {
      Outer ot = new Outer();
       //Line 10
      }
    }

    The following code fragments inserted, for compiling?

    A.New inner(); On line 5
    B.New inner(); On line 10
    C.OT again. Inner(); On line 10
    D.new Outer.Inner (); On line 10

    Answer is A.

    Why not the answer is B?

    well explained by cardan2

    further explanation

    Option A compile without problem

    Option B gives an error - variable not static cannot be referenced from a static context.

    There is no option package C only ot.

    Option D gives an error - variable not static cannot be referenced from a static context.

    hope you get it

  • When I go on a page, the content is not display UNTIL I go in this part of the page. Generally all content on a page is displayed in advance. How should I do?

    The setting was there before. I remember an option for her, but I don't think it's there anymore.

    Hello

    Many issues of the site can be caused by corrupted cookies or cache. To try to solve these problems, the first step is to clear cookies and cache.
    Note: This will be you temporarily disconnect all sites, you're connected to.
    To clear the cache and cookies to do the following:

    1. Go to Firefox > history > clear recent history or (if no Firefox button is displayed) go to tools > clear recent history.
    2. Under "Time range to clear", select "all".
    3. Now, click the arrow next to details to toggle the active details list.
    4. In the list of details, see the Cache and Cookies and uncheck everything.
    5. Now click the clear now button.

    More information can be found in article to clear your cache, history, and other personal information in Firefox .

    ________________________________________________________________________________

    Try Firefox Safe mode to see if the problem goes away. Safe mode is a troubleshooting mode, which disables most of the modules.

    (If you use it, switch to the default theme).

    • Under Windows, you can open Firefox 4.0 + in Safe Mode holding the key SHIFT key when you open the desktop Firefox or shortcut in the start menu.
    • On Mac, you can open Firefox 4.0 + in Safe Mode holding the key option key when starting Firefox.
    • Under Linux, you can open Firefox 4.0 + with leaving Firefox then go to your Terminal and running Safe Mode: firefox-safe-mode (you may need to specify the installation path of Firefox for example/usr/lib/firefox)
    • Or open the Help menu and click on the restart with the disabled... modules menu item while Firefox is running.

    Once you get the pop-up, simply select "" boot mode safe. "

    If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, and you need to understand that one. To do this, please follow article Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems .

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. It might help others who have the same problem.

    Thank you.

Maybe you are looking for

  • Front logo satellite X 200 turned off!

    Hi... my bright logo of edge before Satellite X 200 just turned off and I looked everywhere, but I have no idea how to do to reactivate. Pls can you help me... Thank you

  • Can I install windows 7 ultimate in my three computers?

    If I buy windows 7 ultimate, it allows me to install it in my three computers?

  • 309 a print custom size paper

    My first Photosmart 309 to cannot print custom size paper.  When I try, I get a 'paper mismatch' error when I try to print.  The size that I am trying to print is an invitation of 6 x 9.  I never had this problem with my previous HP printer.

  • Truncate a field before inserting

    Suppose I have the following text:Array: mytablefield: username (VARCHAR2 (35))field: zip (VARCHAR2 (5))I am importing data from an excel with columns username and zip file. A couple of the usernames contains more than 35 characters, and some postal

  • Can not activate Adobe Pro XI after the failure of hard drive

    I had a HARD drive crash and had to install a new hard drive and reload all my programs as Windows 10 backup has not restored correctly.I have re-installed Acrobat Pro XI of a .exe file downloaded a month ago.When I opened Adobe in all the last month