Declare a cursor that can be played back in array of type

Hello

I have a problem - how to declare a cursor that can be played back in array of type.


create or replace type testType as object  
(  
  dokid number(10),          
  name varchar2(20)  
);  
  
CREATE OR REPLACE TYPE testTableType AS TABLE OF testType;  
  
procedure test(  
     author in number      
)   
is  
  tempTable testTableType := testTableType();  
  --cursor type should be changed
  curs out sys_refcursor;
begin  
     --open cursor  
     open curs for  
     select documentID, documentName from documents;
     
     --loop that fetches data
     loop
          FETCH curs 
          BULK COLLECT INTO tempTable LIMIT 100;
          --need bulk collect as table has too many records if used without bulk
          EXIT WHEN curs %NOTFOUND;
          --do some work with temp table
          DBMS_OUTPUT.put_line(tempTable .count || ' rows');
     end loop;
     close curs;
       
      
end test;

First question is why want you to loop through data of cursor? Do it in SQL directly, it is the fastest way to do it.

What about fixing your code, you can go. Code in RED are which I changed.

test procedure
(
the author number
)
is
tempTable testTableType: = testTableType();

curs sys_refcursor;
Start
Open the curs
for
Select testtype (documentID, documentName) in documents;

loop
FETCH Curs
bulk collect into temptable limit 100;
dbms_output.put_line (TEMPTABLE. Count | "lines");
When exit curs % notfound;
end loop;

close the curs;
end test;
/

Tags: Database

Similar Questions

  • I can't play back gammon on the web site of area that he always told me to restart

    I can't play back gammon on the web site of area that he always told me to restart

    Hello

    What site Web access you play Back Gammon?

    If you are referring to the MSN Back Gammon game then the question you posted would be better suited in the support of MSN games. Check out the link and ask the question.
    http://zone.MSN.com/en/support/article/supporttoc.htm

  • How can I play back?

    Hi I can not play back in my laptop please help to me.

    Hello

    Can you post back with what follows.

    1. the complete model number and reference no.. the portable computer (from your laptop service tag).

    2. the full version of the operating system you use (IE Windows 7 32 bit).

    Kind regards

    DP - K

    

  • Can not play back current recording

    I recorded songs using the tape recorder in Vista and they played back fine and always do.

    When I try to save now it looks like his works, the bar moves, readers multimedia window shows all the graphics as it
    plays but no sound. ITunes won't play it either, back to the bar moves as he plays but no sound.

    All the sounds of the music and the window work fine.

    Would be grateful for the help.

    Thank you

    HP G60 laptop

    Hello

    Thanks for choosing Microsoft community.

    By the description I think to understand that there is no sound in Windows media player when you play all audio or video.

    Let me go ahead and help you solve the problem with the sounds in Windows Media player.

    I recommend you follow the steps to solve the problem:


    Troubleshoot audio recording

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-audio-recording-problems

    No sound in Windows

    http://Windows.Microsoft.com/en-us/Windows/no-sound-help#no-sound=Windows-Vista&V1H=win8tab1&V2H=win7tab1&V3H=winvistatab1&v4h=winxptab1

    Tips for solving common audio problems

    http://Windows.Microsoft.com/en-in/Windows-Vista/tips-for-fixing-common-sound-problems

    For everything related to the Windows operating system, do not hesitate to come back to us and we will be happy to help you.

  • Is there a VMware VM that can be play/run under macOS and Windows 7?

    Hello

    I have macbook and desktop Windows 7 at home. Is there a product that I can make a VM and be able to run it in windows 7 and mac?

    Eric

    You will need separate products - VMware Fusion for MAC - and VMware Workstation for Windows 7 with installed products, you should be able to run the same VM 0

    If you find this or any other answer useful please consider awarding points marking the answer correct or useful

  • A list of names that can be used to trigger video specific type embedded videos?

    I would like to make a list of video (as opposed to thumbnails of photo) names that the user could choose to watch only those they wanted on the list?

    These videos come from YouTube, Vimeo, etc.

    If so, please explain how.

    If no, please explain why.

    Ken

    Hi Ken,

    You can use a widget of composition for the same thing. The only change that you need to do is rather than having an image of the thumbnail, place the text you want to use as a trigger for video playback.

    See you soon,.

    Vikas

  • How can I play videos with .xspf file extensions?

    .xspf file extensions?

    How can I play videos with .xspf file extensions?

    Wikipedia

    "XML Shareable Playlist Format (XSPF), pronounced spiff, is an XML- based playlist format for digital media, sponsored by the Xiph.Org Foundation."

    XSPF is a data format for sharing the kind of playlist that can be played on a personal computer or a portable device. In the same way that any user on any computer can open any web page, XSPF is intended to provide portability of the selections. »

    I hope this helps.  Good luck.

  • Question: Poor quality after rotation and can not play on QTime/RealPlayer

    I use EPA, 11 that I just bought and installed. I imported a file (about 600 MB) .avi created on my camera and then turned after the scaling.  I also applied Smart Fix. Two problems: 1. the quality is distinctly inferior to the original and 2. For editing, I don't have an option to select a format that can be played by Qucktime or Real Player. The published file is only about 110 MB. I'm new on this and can't find the answer yet. Thanks Julienl57

    Return on what asked hunting...

    Read Bill Hunt on a file type as WRAPPER http://forums.adobe.com/thread/440037

    What is a CODEC... a primer http://forums.adobe.com/thread/546811

    What CODEC is inside of this file? http://forums.Adobe.com/thread/440037

    .

    A report with the codec of your file details, use the programs below... a screen capture works well for people to SHOW what you do

    http://forums.Adobe.com/thread/592070?TSTART=30

    .

    For PC http://mediainfo.sourceforge.net/en or http://www.headbands.com/gspot/

    For Mac http://mediainspector.massanti.com/

    And some general reading...

    Http://help.adobe.com/en_US/premiereelements/using/index.html user's Guide online

    -Download PDF page current http://helpx.adobe.com/premiere-elements.html

    Import video http://forums.adobe.com/thread/1065281

    - and http://forums.adobe.com/thread/1112086 of the project settings

    Shared savings & http://forums.adobe.com/thread/1137128

    -Sharing of DVD or BluRay http://forums.adobe.com/thread/1137645

    -Sharing for movies http://forums.adobe.com/thread/1051093

    -Sharing of computer http://forums.adobe.com/thread/1058237

    Steve tutorials... basic training steps are the same for several versions

    -http://forums.adobe.com/thread/537685

    -v11 http://www.amazon.com/Muvipix-Guide-Premiere-Elements-version/dp/1479311200/

    FAQ http://forums.adobe.com/community/premiere_elements/premiere_elements_faq

    ADVICE http://forums.adobe.com/community/premiere_elements/premiere_elements_tips

  • How to make a slideshow to be used on blu - ray. I MADE A SLIDE SHOW BUT I CAN NOT PLAY ON BLU

    HOW TO MAKE A SLIDESHOW TO BE USED ON BLU - RAY, I MADE A SLIDESHOW IN LIGHTROOM, BUT I CAN ' FIND A WAY FOR BLU - RAY. JIMBUZZ1

    Lightroom creates a DVD that can be played on other computers.  This includes slideshows.  If you want to be able to show your DVD into a Blu - ray or standard DVD player connected to the TV, then you must use a software that will create the DVD in the proper format.  You might consider ProShow Gold, or Adobe Premiere Elements or similar programs.  According to its capabilities and your TV, you might be able to simply display a regular data DVD images.  My TV has an entry for a flash drive.  I can load the images to a flash drive and view them directly.  But if you want to show your slideshow on your TV, you need to author with appropriate software.

  • I was deleting files and delete something that now I can't play my music files... and my Youtube videos are no longer in sync with the songs. HD playler / Flash...? What I've done. ? How do I get it back

    I was deleting files and delete something that now I can't play my music files... and my Youtube videos are no longer in sync with the songs.  HD playler / Flash...? What I've done. ?  How do I get it back

    Hello

    As you are not sure of what you have removed for cause of your problems, I suggest that do you a system restore to a date before you start deleting these files, and then start carefully again, before to remove any file of dual control.

    How to make a XP system restore:

    http://pcsupport.about.com/od/fixtheproblem/HT/system-restore-XP.htm

    See you soon.

  • How can I fix my CD-ROM drive or a DVD drive that is not recognized by Windows or other programs, so I can't play or access a CD or a DVD.

    How can I fix my CD-ROM drive or a DVD drive that is not recognized by Windows or other programs, so I can't play or access a CD or a DVD. Sometimes, when I click on one of the disks that it opens, but the page for the drive is empty. It also says to insert a disk, sometimes when there is a disc in the drive. How this can be fixed.

    Hi vtdubu,

    ·         Did you do changes on the computer before the show?

    Follow the steps in the article.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs

    http://support.Microsoft.com/kb/982116

    Note: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following link. http://support.Microsoft.com/kb/322756

  • How can I play old games that run on Windows 95?

    I bought a new computer with the latest windows os; How can I play old games that run on Windows 95?

    BOX BACK is good for the old games based DOX.
    Try the program below, it provides an interface that makes a little BACK BOX
    friendly.

    D - Fend Reloaded: overview

    Some Windows 98 games will still install on Win7, more with 32-bit because of old 16-bit
    installers is not not compatible with 64-bit OS. Others have workarounds and fixes, solutions
    their fan sites.

    Virtual machines can be useful as well-

    Overview of VirtualBox

    | MG | Download VirtualBox 4.1.10.76836

    Good old games web site has a lot of older games to download already settle
    with a BOX BACK if necessary.

    http://www.Gog.com
    .

  • When I try to connect to the games, it just goes back to my home page. I can't play games, the screen just goes back to any page, I was already on

    When I try to connect to the games, it just goes back to my home page.  I can't play all games, the screen just goes back to any page, I was previously on.

    Hello Gary,.

    Thanks for posting your query on the Microsoft Community.

    The information provided by you are not enough to provide us with troubleshooting. It would be much appreciated if you could provide us with the following information.

    1. Are you facing problem with this game alone or with all games?
    2. Are all the device drivers and updates of Windows updated?
    3. You did it all change important before the show?
    4. Have any security software installed on your system?

    According to the title of your question, you can not open the collection of Microsoft solitaire on your computer. The question could be if some security software is limiting to open. It could also be if there is a corruption in the application. If you get a black screen during game play then it could also be due to drivers. So try to follow the steps below and see if it helps you to solve the problem.

    Method 1.

    You can temporarily disable the security software and check if it allows to open the game on your computer.

    Warning: If you need to temporarily disable the antivirus to install other software. You must enable the antivirus as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to virus attacks.

    If the problem persists, go to the next method and see if it helps.

    Method 2:
    Step 1:

    Please go to the link below, download the file and run it.

    Run applications troubleshooting

    Download and run the troubleshooter modern UI App.

    http://download.Microsoft.com/download/F/2/4/F24D0C03-4181-4E5B-A23B-5C3A6B5974E3/apps.diagcab

    Step 2:

    I suggest to go through the link and follow the given procedure. Here is the link for your reference.

    What to do if you have problems with a soft

    http://Windows.Microsoft.com/en-GB/Windows-8/what-troubleshoot-problems-app

    After the execution of the method 1 try to open applications to be updated.

    Method 3

    If the problem persists, try to update the drivers supplied by the steps mentioned in the article below. Drivers are updated occasionally. Windows can update automatically, or you can install the drivers updated yourself. It is important for you to have confidence in the updated drivers that you install.

    Download and install the drivers

    Get back to us with all the necessary information and the result of the proposed suggestion. We will be happy to help you.

    Kind regards

  • Can we declare a cursor in the Specs of package?

    Dear friends
    I can declare a cursor in the package Specs so that I can call this slider and use its data in certain procedures and functions of the package. Otherwise I have to write this slider for each subprogramme of a package which I'm not a clever way to accomplish the task.

    Hello

    Here is a short example with all the way down. Perhaps the concept becomes more clear with this:

    first of all, if you do not have the table emp, here the DDL for this example.
    Attention, only works for German customers because the names of the months, sorry for that.

    CREATE TABLE EMP
    (EMPNO NUMBER(4) NOT NULL,
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(7, 2),
    COMM NUMBER(7, 2),
    DEPTNO NUMBER(2));
    set echo on
    
    INSERT INTO EMP VALUES
    (7369, 'SMITH', 'CLERK', 7902,
    TO_DATE('17-DEZ-1980', 'DD-MON-YYYY'), 800, NULL, 20);
    INSERT INTO EMP VALUES
    (7499, 'ALLEN', 'SALESMAN', 7698,
    TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30);
    INSERT INTO EMP VALUES
    (7521, 'WARD', 'SALESMAN', 7698,
    TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
    INSERT INTO EMP VALUES
    (7566, 'JONES', 'MANAGER', 7839,
    TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
    INSERT INTO EMP VALUES
    (7654, 'MARTIN', 'SALESMAN', 7698,
    TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
    INSERT INTO EMP VALUES
    (7698, 'BLAKE', 'MANAGER', 7839,
    TO_DATE('1-MAI-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
    INSERT INTO EMP VALUES
    (7782, 'CLARK', 'MANAGER', 7839,
    TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
    INSERT INTO EMP VALUES
    (7788, 'SCOTT', 'ANALYST', 7566,
    TO_DATE('09-DEZ-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7839, 'KING', 'PRESIDENT', NULL,
    TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
    INSERT INTO EMP VALUES
    (7844, 'TURNER', 'SALESMAN', 7698,
    TO_DATE('8-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30);
    INSERT INTO EMP VALUES
    (7876, 'ADAMS', 'CLERK', 7788,
    TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
    INSERT INTO EMP VALUES
    (7900, 'JAMES', 'CLERK', 7698,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 950, NULL, 30);
    INSERT INTO EMP VALUES
    (7902, 'FORD', 'ANALYST', 7566,
    TO_DATE('3-DEZ-1981', 'DD-MON-YYYY'), 3000, NULL, 20);
    INSERT INTO EMP VALUES
    (7934, 'MILLER', 'CLERK', 7782,
    TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);
    

    2. package Spec:

    create or replace
    package test_cursor as 
    
      --Type for the returncode of the function
      TYPE typ_emp IS TABLE OF emp%rowtype;
    
      --Array for fetching, of course also possible in the body
      t_emp typ_emp;
    
      --function wich returns the array from fetching the cursor
      function get_emp return typ_emp;
    
      --function for manupilation data retrieved by the function
      PROCEDURE man_emp;
    
    end test_cursor;
    

    3. package body

    create or replace
    package body test_cursor as
    
      FUNCTION get_emp RETURN typ_emp AS
    
      cursor c_emp is select * from emp;
    
      BEGIN
        open c_emp;
    
        fetch c_emp BULK COLLECT INTO t_emp;
    
        CLOSE c_emp;
    
        --t_emp returns the whole table set from emp
        return t_emp;
      end get_emp;
    
      PROCEDURE man_emp AS
      --just for not confusing names, is the same as t_emp of course
      v_emp_array typ_emp;
    
      BEGIN
        --call the function and retrieve the whole data set
        v_emp_array := get_emp;
    
        --now manipulate the data, in this case just write the names to the calling client
        FOR rec IN v_emp_array.FIRST .. v_emp_array.LAST
        loop
          dbms_output.put_line(v_emp_array(rec).ename);
        end loop;
    
      end man_emp;
    
    end test_cursor;
    

    4. the procedure call

    SET serveroutput ON
    exec test_cursor.man_emp;
    

    5. and here's the result:

    anonymer Block abgeschlossen
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    

    Please be aware, it's just for demonstration purposes, of course, it makes no sense to display names in this way. But how to call a function return tables with sets of data recovery of the sliders is shown here.

    HTH

    Joerg

  • My computer is iMac, in late 2012. 2.9 GHz, 8 GB.  Updated yesterday at El Capitan.  IT is so slow, I can't do anything.  Can I go back to my previous operating system? How do I do that?

    My computer is iMac, in late 2012. 2.9 GHz, 8 GB.  Updated yesterday at El Capitan.  IT is so slow, I can't do anything.  Can I go back to my previous operating system? How do I do that?

    Before giving up the 10.11, let's see if we can find what is the problem... Download and run EtreCheck, created by one of his own assistants here in CSA. It is a diagnostic tool that is very useful for us to find problems. It will also give us additional specifications on your Mac. After his execution after the logfile here. It will never contain any personal information

Maybe you are looking for