INVALID CURSOR - block anonymous component the cursor in function

I get an error when you try to call my cursor.
CREATE OR REPLACE PACKAGE tax_update
AS
 TYPE gencur IS ref cursor;
 FUNCTION tax_sf
 (
   p_state IN bb_tax.state%type,
   p_thecursor IN OUT gencur
 )
 RETURN NUMBER;
END;
/ 
CREATE OR REPLACE PACKAGE BODY tax_update
AS
 FUNCTION tax_sf
 (
   p_state IN bb_tax.state%type,
   p_thecursor IN OUT gencur
 )
 RETURN NUMBER
  IS
  lv_taxrate NUMBER;
 BEGIN
  OPEN p_thecursor FOR 
   SELECT taxrate 
   FROM bb_tax
   WHERE state = p_state;
  RETURN lv_taxrate;
 END;
END;
/ 
DECLARE
  tax_cur tax_update.gencur;
  rec_tax bb_tax%rowtype;
 BEGIN
 LOOP
  FETCH tax_cur INTO rec_tax;
   EXIT WHEN tax_cur%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
 END LOOP;
END;
DECLARE
*
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at line 6
Mission is to create a package that will contain the rate of taxation by the State in a packed slider. The package contains a function that can receive a State of 2 character abbreviated as an argument and finds a match in the cursor and return the tax rates for tha tstate. An anonymous block will test the function with the State of North Carolina.
If anyone can help?

user13842802 wrote:
Have tried a few ways to call but always error on TAX_SF.

SET SERVEROUTPUT ON
DECLARE
    tax_cur tax_update.gencur;
    rec_tax bb_tax%rowtype;
BEGIN
    tax_cur := tax_update.tax_sf('NC');
    LOOP
      FETCH tax_cur INTO rec_tax;
      EXIT WHEN tax_cur%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate);
    END LOOP;
END;
/

SY.

Tags: Database

Similar Questions

  • Invalid cursor within the service in pipeline

    The simple example following illustrates a mistake that I am experiencing with development code more complex.

    I try to reuse a complex procedure that I do not have duplication of code and business logic.

    It runs correctly.

    exec PKG_TEST.complex_proc(:p_cursor);

    This property returns an error:

    exec PKG_TEST.select_rows(:p_cursor);

    The error is ORA-01001: Invalid cursor.

    I checked and the cursor is opened and % notfound is false.

    Any ideas?

    Thank you in advance for your help!

    create the table employees

    (

    primary key ID number,

    name varchar2 (100)

    );

    insert into employee values (1, 'Joe');

    insert into employee values (2, 'Bob');

    insert into employee values (3, 'Peter');

    create table contractor

    (

    primary key ID number,

    name varchar2 (100)

    );

    insert into a values (4, 'Henry') contractor;

    insert into contractor values (5, 'William');

    create or replace package PKG_TEST

    is

    type t_rec is rendered

    (

    Identification number,

    name varchar (100)

    );

    type t_tab is table of the t_rec;

    procedure complex_proc (p_cursor to sys_refcursor);

    function select_fn (p_cursor sys_refcursor)

    return PKG_TEST.t_tab in pipeline;

    select_rows (p_cursor to sys_refcursor) procedure;

    end pkg_test;

    create or replace package PKG_TEST body

    is

    procedure complex_proc (out p_cursor sys_refcursor)

    is

    Start

    Open the p_cursor for

    Select *.

    the employee;

    end complex_proc;

    function select_fn (p_cursor sys_refcursor)

    return PKG_TEST.t_tab pipeline

    is

    v_tab PKG_TEST.t_tab;

    v_rec PKG_TEST.t_rec;

    Start

    loop

    collect the fetch p_cursor in bulk in the v_tab limit 100;

    because me in 1... v_tab. Count

    loop

    v_rec: = v_tab (i);

    pipe row (v_rec);

    end loop;

    When the output p_cursor % NOTFOUND;

    end loop;

    return;

    end select_fn;

    select_rows (exit p_cursor sys_refcursor) procedure

    is

    v_cursor sys_refcursor;

    Start

    PKG_TEST.complex_proc (v_cursor);

    Open the p_cursor for

    Select *.

    table (PKG_TEST.select_fn (v_cursor))

    Union of all the

    Select *.

    contractor;

    select_rows end;

    end pkg_test;

    Problem is that your variable v_cursor in SELECT_ROWS is out of scope when the procedure ends.

    So the ref cursor returned by this method cannot be referenced it more.

    If you are on 11g and beyond, a workaround is to declare v_cursor DBMS_SQL cursor (for example an INTEGER data type) and use DBMS_SQL.to_cursor_number / DBMS_SQL.to_refcursor to convert between the two.

    In this way, the query pointed to by the final Ref cursor will always have a valid binding variable when the procedure ends.

    function select_fn( p_cursor in integer )
    return PKG_TEST.t_tab pipelined
    is
    
      v_tab         PKG_TEST.t_tab;
      v_rec         PKG_TEST.t_rec;
      v_cursor_num  integer := p_cursor;
      v_cursor      sys_refcursor := dbms_sql.to_refcursor(v_cursor_num);
    
    begin
    
      loop
    
        fetch v_cursor bulk collect into v_tab limit 100;
    
        --exit when p_cursor%NOTFOUND;
        exit when v_tab.count = 0;
    
         for i in 1 .. v_tab.count
         loop
            v_rec := v_tab(i);
            pipe row(v_rec);
         end loop;
    
      end loop;
    
      close v_cursor;
    
      return;
    
    end select_fn;
    
    procedure select_rows ( p_cursor out sys_refcursor )
    is
       v_cursor  sys_refcursor;
       v_cursor2 integer;
    begin
       PKG_TEST.complex_proc(v_cursor);
    
       v_cursor2 := dbms_sql.to_cursor_number(v_cursor);
    
       open p_cursor for
       select *
       from TABLE(PKG_TEST.select_fn(v_cursor2))
       union all
       select *
       from contractor;
    
    end select_rows;
    
  • Initialize the Ref Cursor to avoid ORA-01001: Invalid cursor

    Hello

    I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.

    Any help is greatly appreciated...

    Thank you
    Christine

    cad0227 wrote:
    Hello

    I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.

    Any help is greatly appreciated...

    Thank you
    Christine

    The most appropriate way would be the caller to handle the situation. The caller must capture the exception of INVALID_CURSOR and do what is necessary.

    Other suggestions like having a separate Pavilion or a model select all will lead the appellant to act to the particular situation, that slider is not being opened. What is the case with the exception of INVALID_CURSOR raised by oracle.

    All the need for the appellant to do is manage the exception of INVALID_CURSOR and you should be good. And also INVALID_CURSOR is not a mistake, it's an exception that has a special meaning for her. In the case you sense it takes the condition when not together to return a cursor.

  • Purge to open payable Interface ends with the error "Invalid Cursor"

    Hello

    I'm running Purge of open accounts payable (version 115.8) Interface and get an error of invalid cursor in the beforereport trigger. No one knows the cause and the cure for it? Part of the log is below. I looked at the cursor level and everything seems fine for me.

    MSG-00001: Check (Import_purge 1) Panel for the purge process
    MSG-00001: (Check_control_table 1) to lock the table control
    MSG-00003: Fetch (Check_control_table 2) import_requests
    MSG-00004: (Check_control_table 3) check the status of concurrent program
    MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
    MSG-00999: FND_CONCURRENT. GET_REQUEST_STATUS <-Check_control_table <-Import_purge <-pre-writ report <-APXIIPRG
    MSG-00999: check_control_table <-Import_purge <-pre-writ report <-APXIIPRG
    MSG-00999: Check (Import_purge 1) Panel for the purge process
    MSG-00999: delete the record in the command table...
    MSG-00999: ORA-01001: Invalid cursor
    REP-1419: 'beforereport': program abandoned PL/SQL.

    Thank you.

    I'm running Purge of open accounts payable (version 115.8) Interface and get an error of invalid cursor in the beforereport trigger. No one knows the cause and the cure for it? Part of the log is below. I looked at the cursor level and everything seems fine for me.

    MSG-00001: Check (Import_purge 1) Panel for the purge process
    MSG-00001: (Check_control_table 1) to lock the table control
    MSG-00003: Fetch (Check_control_table 2) import_requests
    MSG-00004: (Check_control_table 3) check the status of concurrent program
    MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
    MSG-00999: FND_CONCURRENT. GET_REQUEST_STATUS<><><- before="" report="" trigger=""><->
    MSG-00999: check_control_table<><- before="" report="" trigger=""><->
    MSG-00999: Check (Import_purge 1) Panel for the purge process
    MSG-00999: delete the record in the command table...
    MSG-00999: ORA-01001: Invalid cursor
    REP-1419: 'beforereport': program abandoned PL/SQL.

    11i: debt open Interface import bill (APXIIMPT) [ID 107628.1] Troubleshooting Guide - 3. Open the Purge Import Interface fails with ORA-01001: Invalid cursor

    Thank you
    Hussein

  • PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type

    Hello

    Having a little trouble with the following code example provided to http://www.dba-oracle.com/plsql/t_plsql_cursor_variables.htm:
      1  DECLARE
      2    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
      3    c_cursor  t_ref_cursor;
      4    l_row   NUMBER;
      5  BEGIN
      6    DBMS_OUTPUT.put_line('Strongly typed REF CURSOR using SCALAR type. Expect an error!');
      7    OPEN c_cursor FOR
      8      SELECT COUNT(*) cnt
      9      FROM   cursor_variable_test;
     10    LOOP
     11      FETCH c_cursor
     12      INTO  l_row;
     13      EXIT WHEN c_cursor%NOTFOUND;
     14      DBMS_OUTPUT.put_line(l_row);
     15    END LOOP;
     16    CLOSE c_cursor;
     17* END;
     18  /
      TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
                           *
    ERROR at line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Item ignored
    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?

    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?

    Thank you very much
    Jason

    >
    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
    *
    ERROR on line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Ignored Element

    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?
    >
    The exception is in line 2: your cursor statement. And the answer is in the text that you access
    >
    The return value of a strongly typed REF CURSOR must be a folder that can be defined using % TYPE % ROWTYPE attributes or record structure.
    >
    You said the CURSOR to return a NUMBER. And as the text says, he must be a 'record '.
    >
    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
    >
    As you said already FETCH retrieves the next line, if any. A query is a request is a request. It returns a result set. A query that uses aggregates returns a result set. A query that does not aggregate returns a result set.

    Your simple COUNT (*) SELECT query returns a result set that consists of a LINE and a line a ONE COLUMN of type NUMBER. Although there is only one column in the result set, what is returned is a RECORD or a LINE. That's why you have to report your data cursor return type a document using the % ROWTYPE or % TYPE attributes or a record structure.

  • Invalid cursor error

    When I try to run the following pl/sql code, I get error of invalid cursor. Can someone please explain to me where I am doing wrong.
    DECLARE
    CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees;
    
    
    EMP_REC C1%ROWTYPE;
    
    BEGIN
    FOR REC IN C1
    LOOP
    FETCH C1 INTO EMP_REC;
    EXIT WHEN C1%NOTFOUND;
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary);
    END LOOP;
    END;
    Thanks in advance!

    You must decide if you want to open the cursor implicit or explicit:

    You can use:

    Variant1

    DECLARE
    CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees;
    
    BEGIN
    FOR REC IN C1
    LOOP
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary);
    END LOOP;
    END;
    

    Variant2:

    DECLARE
    CURSOR C1 IS SELECT id employee_id, name last_name, id salary FROM arzt where rownum<10;
    
    EMP_REC C1%ROWTYPE;
    
    BEGIN
    open c1;
    loop
    FETCH C1 INTO EMP_REC;
    EXIT WHEN C1%NOTFOUND;
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||emp_REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||emp_REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||emp_REC.salary);
    END LOOP;
    END;
    

    Published by: hm on 01.08.2011 00:12

  • Can block anonymous calls or no calls the caller ID?

    Can block anonymous calls or no calls the caller ID?

    N °

  • Block based on the stored procedure cannot modify Default_where clause

    Hi all

    I tried to create a block based on the stored procedure that it works very well with the result set for the refcursor. But if I need to add filters on the block using where clause in the palette of goods or

    using the property block set in where clause, it does not error but does not review filters .

    tried everything to you please let me know. This is a restriction whereby we can set filters on the block when we create the block based on the stored procedure.

    Thank you

    Check in Form Builder Help:

    Creating a block of data from a procedure that uses a ref cursor

    ... You can't pass a WHERE or ORDER BY clause clause in a stored procedure.

    But you can send your WHERE condition using the query Source Arguments.

    If the procedure is on the side of the database (not in the forms module), ensure that the procedure is not vulnerable to injection of SQL code.

    Kind regards

    Zlatko

  • Blocking rotation of the screen - 4.6.1 SDK

    Follow the latest code I did:

    What's up guys!
    I'm trying to run an application on curve 8520 and tourch 9800, so I use sdk4.6.1.
    I would block the rotation of the screen on the torch, but I know that the 4.6 SDK is no such API. I tried to override the paint method and invalidate sublayout, trying to put the paintSuspend as true.
    I need, in addition to block rotation, ask the user to return to the correct orientation (portrait), but dialogue does not work.

    My last code below:

    public final class MyScreen extends MainScreen {
     ...
     public void invalidate() {
            String deviceName = DeviceInfo.getDeviceName();
            int width = Display.getWidth();
            int height = Display.getHeight();
    
            System.out.println("diogo ------------display: " + width + " " + height + " name" + deviceName);
    
            if (width == 480 && height == 360 && deviceName.equalsIgnoreCase("9800")) {
    
                synchronized (UiApplication.getEventLock()) {
    
                    loadingDialog.setEscapeEnabled(false);
                    loadingDialog.doModal();
    
                    UiApplication.getUiApplication().suspendPainting(true);
                    System.out.println(UiApplication.getUiApplication().isPaintingSuspended());
    
                    return;
    
                }
            } else {
                if (UiApplication.getUiApplication().isPaintingSuspended())
                    UiApplication.getUiApplication().suspendPainting(false);
                loadingDialog.close();
            }
            super.invalidate();
        }
    }
    

    Might be easier to upgrade your 8520 for OS 5.0!

    I looked at your code seriously not, but invalid do seems to be a dangerous place to do so.

    I'd do it in sublayout.  sublayout is called when the rotation is detected.

    If you detect a rotation, then to sublayout, create an invokeLater (you will not be able to do this kind of thing in sublayout, you must start a new process).  The invokeLater push a new screen of your production.  In sublayout of the screen, check the orientation by using the width and height.  When that detects the correct orientation. have pop himself (in another invokeLater.  I think it should work and hooks in a defined place.

    Ask if this is not clear.

  • Block Member component select only members of dense dimension

    I used the calculation Manager to create business for the planning application rule. The block Member component display only the dense dimensions. Why?

    His tent to force yourself to write the computation of optimally. Calculations with blocks of scattered members are much slower than the dense blocks. Even if you cannot select, you can always type in the name of sparse dimension member. You need not use the Member picker.

  • is itunes error message cannot connect to my iphone because of an invalid response was received from the device

    get error message that IOS 10 unable to connect to my iphone iTunes 6 because of an invalid response was received from the device

    Make sure you are using iTunes 12.5.1 or later, as it is required to communicate to iOS 10.

    If iTunes does not recognize your iPhone, iPad or iPod - Apple Support

  • iTunes could not connect to the iPhone "iPhone", because an invalid response was received from the device.

    So I am a new iphone 7. I had a 6 before that. Everything was fine until the day where I got the 7, I decided to try a manual on itunes for my 6 backup so that I could put this on the new phone. I use now icloud backup but before that he always did on my computer. Its itunes version 12.2.2.25 as it is the most recent, that I can run with 10.7.5 which is the newest my mac pro can work without hacking it. Again, never had a problem before it save and use it to transfer music. Anyway, I received the message "iTunes could not connect to the iPhone"iPhone"because an invalid response was received from the device." I tried 3 different usb cords. I tried both ports to the front of the computer and all 3 in the back. Abandoned and did a backup icloud. Installed on the new phone. Everything transferred except my music library which is real download of my CD via itunes. If something was wrong on the iphone 6, surely the new phone that starts with a clean slate will be very well... wrong.  Same message. Leaves through ports, cables, etc. Is it just a simple matter of ios 10 now works with my version of itunes?

    A new phone will be iOS10.  iOS10 requires iTunes 12.5.1 find which demands in turn 10.9.5 OSX or newer.  Software update checks only the updates to the current version of the system that you are running but that itself can be updated.  It may or may not be possible to upgrade your computer to the system requirements. Find your computer on the web site of http://www.everymac.com model and near the bottom of the specification of the system section, he will tell what versions of the operating system, it is able to run. If you can not run a newer system, you will not be able to sync this phone to your current computer. OSX 10.9 and 10.10 are no longer available. You can try to install the free El Capitan OSX 10.11.  El Capitan can run slower on older machines and require the additional purchase of RAM (4 GB is a minimum realistic and many recommend 8 GB).  Making a big jump in versions of system is also more likely to affect the old software.

    At el capitan Snow Leopard, it will make my macbook is slow?  - https://discussions.apple.com/thread/7412959

    Course OSX Upgrade General information, including configuration required - http://www.apple.com/osx/how-to-upgrade/

  • iTunes could not connect to the iPhone, because an invalid response was received from the device.

    Just bought an iPhone 7 today and received the error message "iTunes could not connect to the iPhone because an invalid response was received from the device." Don't know what that means, and I have never had this problem with one of my previous iPhones. Thank you.

    You run iTunes 7.5.1? iOS10 requires iTunes 12.5.1 find which demands in turn 10.9.5 OSX or newer.  Software update checks only the updates to the current version of the system that you are running but that itself can be updated.  It may or may not be possible to upgrade your computer to the system requirements. Find your computer on the web site of http://www.everymac.com model and near the bottom of the specification of the system section, he will tell what versions of the operating system, it is able to run. If you can not run a newer system, you will not be able to sync this phone to your current computer. You can try to install the free El Capitan OSX 10.11.  El Capitan can run slower on older machines and require the additional purchase of RAM (4 GB is a minimum realistic and many recommend 8 GB).  Making a big jump in versions of system is also more likely to affect the old software.

    At el capitan Snow Leopard, it will make my macbook is slow?  - https://discussions.apple.com/thread/7412959

    Course OSX Upgrade General information, including configuration required - http://www.apple.com/osx/how-to-upgrade/

    If you have any generation of PPC software which works under OSX 10.6 it is not supported in later versions of the system.

  • Invalid response was received from the device

    Now that I've updated my iOS 10 6plus my phone will not connect to my macbook pro. I get an error message stated "iTunes only could not connect to iPhone because an invalid response was received from the device. I removed the password and fingerprints, phone rebooted, macbook restarted and still does not.

    Hi kcampagna8,

    Thank you for using communities Support from Apple. We are sorry you are experiencing this problem with your iPhone. If you get an error with "an invalid response" message when you try to connect to iTunes, you can find the troubleshooting steps in the following article useful:

    Check your USB connections

    If you see the error 4005, 4013, 4014, learn what to door. If you see one of the errors below, you might have a USB connection problem:

    • 13, 14, 1600, 1601, 1602, 1603, 1604, 1611, 1643-1650
    • 2000, 2001, 2002, 2005, 2006, 2009
    • An error message that includes, "an invalid response.

    Follow these steps to see if the problem is with your USB cable, a USB port or computer. Try again after each step:

    1. Use the USB cable supplied with your device. If you do not, try a different cable USB Apple.
    2. Switch to a different USB port on your computer. Do not connect on your keyboard.
    3. Plug it into another computer.
    4. If you still see the error, you can check for any other problem USB, with the third-party security softwareand the problems with hardware.

    If the problem persists, contact The Apple support.

    Get help with iOS update or restore errors - Apple Support

    Concerning

  • -What it means and how to fix it? iTunes could not connect to the iPhone from the iPhone Simon Young, because an invalid response was received from the device.

    iTunes could not connect to the iPhone "IPhone by Simon Young", because an invalid response was received from the device.

    You have upgraded to iTunes 12.5.1? iOS10 requires iTunes 12.5.1 find which demands in turn 10.9.5 OSX or newer.  Software update checks only the updates to the current version of the system that you are running but that itself can be updated.  It may or may not be possible to upgrade your computer to the system requirements. Find your computer on the web site of http://www.everymac.com model and near the bottom of the specification of the system section, he will tell what versions of the operating system, it is able to run. You can try to install the free El Capitan OSX 10.11.  El Capitan can run slower on older machines and require the additional purchase of RAM (4 GB is a minimum realistic and many recommend 8 GB).  Making a big jump in versions of system is also more likely to affect the old software.

    At el capitan Snow Leopard, it will make my macbook is slow?  - https://discussions.apple.com/thread/7412959

    Course OSX Upgrade General information, including configuration required - http://www.apple.com/osx/how-to-upgrade/

    If you have any generation of PPC software which works under OSX 10.6 it is not supported in later versions of the system.

Maybe you are looking for