Pls-00225 subprogram or cursor reference is out of scope solution

Hi ,
Below is my code. i am getting cursor out of scope error. pls provide solution
CREATE OR REPLACE PROCEDURE reconcile_dna
IS
CURSOR dna_host IS SELECT * FROM t_dna_stage;
dna_host_cur dna_host%rowtype;
CURSOR server_host IS SELECT * FROM t_servers WHERE rec_flag = 'N';
server_host_rec server_host%rowtype;
vhostserver_cnt NUMBER := 0;
vhost_cnt NUMBER := 0;
vhostdna_cnt NUMBER := 0;
vserver_cnt NUMBER := 0;
BEGIN
DBMS_OUTPUT.put_line ('******Reconciliation Started******');
UPDATE t_servers
SET rec_flag = 'N';
-- Updating t_servers table to set rec_flag='N' before starting the reconciliation process
BEGIN
DBMS_OUTPUT.put_line ('******Inside Reconciliation ******');
OPEN dna_host;
LOOP
FETCH dna_host INTO dna_host_cur;
EXIT WHEN dna_host%NOTFOUND;
SELECT COUNT (*) -- searching in t_server table
INTO vhost_cnt
FROM t_servers
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
IF vhost_cnt > 0
THEN
UPDATE t_servers
-- Updating t_server table if hostname found in dna data
SET rec_flag = 'Y'
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
SELECT COUNT (*)
-- searching in t_dna_defects table for reconciled hostnames
INTO vhostserver_cnt
FROM t_dna_defects
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
IF vhostserver_cnt > 0
THEN
UPDATE t_dna_defects
-- Updating t_dna_defects table when hostname reconciled in t_servers
SET remediate_date = SYSDATE,
active = 'N',
last_update_by = '502061473',
last_update_date = SYSDATE
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
END IF;
ELSE
SELECT COUNT (*)
-- searching in t_dna_defects table if hostname notfound in t_server table
INTO vhostdna_cnt
FROM t_dna_defects
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
IF vhostdna_cnt > 0
THEN
UPDATE t_dna_defects
-- Updating t_dna_defects table when hostname found in t_dna_defects
SET COUNT = COUNT + 1,
last_found_date = SYSDATE,
last_update_by = '502061473',
last_update_date = SYSDATE,
active='Y'
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
ELSE
INSERT INTO t_dna_defects
-- Inserting hostname information record in t_dna_defects table when not found in t_server and t_dna_defects
( reconcile_id, hostname,
os, ip_address, business,
business_unit,
reporting_business_unit,
userid, city,
state, country, active, COUNT,
first_found_date, last_found_date,
created_by, creation_date
VALUES (recon_id_seq.NEXTVAL, dna_host_cur.hostname,
dna_host_cur.os, dna_host_cur.ip, dna_host_cur.business,
dna_host_cur.businessunit,
dna_host_cur.reportingbusinessunit,
dna_host_cur.userid, dna_host_cur.city,
dna_host_cur.state, dna_host_cur.country, 'Y', 1,
SYSDATE, SYSDATE,
'502061473', SYSDATE
END IF;
END IF;
END LOOP;
close dna_host;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line ('In Exception step 1 ERROR IS'||SQLCODE||' '||SQLERRM);
END;
BEGIN
DBMS_OUTPUT.put_line ('************Reconciliation step 2******');
OPEN server_host;
LOOP
FETCH server_host INTO server_host_rec;
EXIT WHEN server_host%NOTFOUND;
SELECT COUNT (*)
INTO vserver_cnt
FROM t_server_defects
WHERE LOWER (hostname) = LOWER (server_host_rec.hostname);
IF vserver_cnt > 0
THEN
UPDATE t_server_defects
SET last_found_date = SYSDATE,
COUNT = COUNT + 1,
ACTIVE='Y';
ELSE
INSERT INTO t_server_defects
(reconcile_id, hostname, active,
first_found_date, last_found_date, remediate_date
VALUES (recon_id_seq.NEXTVAL, server_host_rec.hostname, 'Y',
SYSDATE, SYSDATE, NULL
END IF;
END LOOP;
CLOSE server_host;
UPDATE t_server_defects
SET ACTIVE='N'
where trunc(last_found_date)<>trunc(sysdate);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('****Inside exception for step 2******');
DBMS_OUTPUT.put_line ('ERROR IS'||SQLCODE||' '||SQLERRM);
END;
COMMIT;
END;
Regards,
Tiru

Would you please edit your post and put formatted code between 'code' tags as discussed in the FAQ.
This code needs to be rewritten. It uses loops and multiple queries to do simple updates.
For example the first query in this code
SELECT COUNT (*) -- searching in t_server table
INTO vhost_cnt
FROM t_servers
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
IF vhost_cnt > 0
THEN
UPDATE t_servers
-- Updating t_server table if hostname found in dna data
SET rec_flag = 'Y'
WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);isn't even needed - just do the second UPDATE - if there aren't any rows to update then nothing will be updated? The first query would only be beneficial if the normal case is that there are no records to be updated. For cases where there are records to be updated you are executing two queries when one would do the job. And both queries will use full table scans unless you have functional indexes on both 'hostname' columns.
You then have two more sets of queries that use two queries instead of one.
I suggest you remove the extra queries, and then put the remaining formatted code in 'code' tags. The code will be simpler, perform better and be easier to see what your problem is.

Similar Messages

  • PLS-00225: subprogram or cursor reference is out of scope

    I am trying to create a PL/SQL program to extract values from a table that has an XML data type. I created the SQL to extract the elements but when I put it into a PL/SQL program I get an error that points to a line in the SQL code that runs fine on it’s own.
    I stripped the PL/SQL code down to the simplest from in order to debug
    DECLARE
    cursor cur_asset_info IS
    SELECT extract(value(a1), '//ASSET_ID[1]/text()').getStringVal() AS "ASSET_ID",
    extract(value(a1), '//ASSET_ID[2]/text()').getStringVal() AS "IP_ADDRESS",
    extract(value(a1), '//IDENTIFIER/text()').getStringVal() AS "DB_IDENTIFIER",
    extract(value(a1), '//PARENT_KEY/text()').getStringVal() AS "PARENT_KEY"
    FROM scanxml_tbl p,
    table(xmlsequence(extract( p.object_value, '/IMPORT_FILE/ASSET')))a1;
    BEGIN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END
    When I run this I get:
    Error report:
    ORA-06550: line 8, column 35:
    PLS-00225: subprogram or cursor 'P' reference is out of scope
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    I am not exactly sure why I get the error.
    Thanks,
    Chris

    Hi ,
    Below is my code where is the issue.pls provide solution
    CREATE OR REPLACE PROCEDURE reconcile_dna
    IS
    CURSOR dna_host IS SELECT * FROM t_dna_stage;
    dna_host_cur dna_host%rowtype;
    CURSOR server_host IS SELECT * FROM t_servers WHERE rec_flag = 'N';
    server_host_rec server_host%rowtype;
    vhostserver_cnt NUMBER := 0;
    vhost_cnt NUMBER := 0;
    vhostdna_cnt NUMBER := 0;
    vserver_cnt NUMBER := 0;
    BEGIN
    DBMS_OUTPUT.put_line ('******Reconciliation Started******');
    UPDATE t_servers
    SET rec_flag = 'N';
    -- Updating t_servers table to set rec_flag='N' before starting the reconciliation process
    BEGIN
    DBMS_OUTPUT.put_line ('******Inside Reconciliation ******');
    OPEN dna_host;
    LOOP
    FETCH dna_host INTO dna_host_cur;
    EXIT WHEN dna_host%NOTFOUND;
    SELECT COUNT (*) -- searching in t_server table
    INTO vhost_cnt
    FROM t_servers
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    IF vhost_cnt > 0
    THEN
    UPDATE t_servers
    -- Updating t_server table if hostname found in dna data
    SET rec_flag = 'Y'
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    SELECT COUNT (*)
    -- searching in t_dna_defects table for reconciled hostnames
    INTO vhostserver_cnt
    FROM t_dna_defects
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    IF vhostserver_cnt > 0
    THEN
    UPDATE t_dna_defects
    -- Updating t_dna_defects table when hostname reconciled in t_servers
    SET remediate_date = SYSDATE,
    active = 'N',
    last_update_by = '502061473',
    last_update_date = SYSDATE
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    END IF;
    ELSE
    SELECT COUNT (*)
    -- searching in t_dna_defects table if hostname notfound in t_server table
    INTO vhostdna_cnt
    FROM t_dna_defects
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    IF vhostdna_cnt > 0
    THEN
    UPDATE t_dna_defects
    -- Updating t_dna_defects table when hostname found in t_dna_defects
    SET COUNT = COUNT + 1,
    last_found_date = SYSDATE,
    last_update_by = '502061473',
    last_update_date = SYSDATE,
    active='Y'
    WHERE LOWER (hostname) = LOWER (dna_host_cur.hostname);
    ELSE
    INSERT INTO t_dna_defects
    -- Inserting hostname information record in t_dna_defects table when not found in t_server and t_dna_defects
    ( reconcile_id, hostname,
    os, ip_address, business,
    business_unit,
    reporting_business_unit,
    userid, city,
    state, country, active, COUNT,
    first_found_date, last_found_date,
    created_by, creation_date
    VALUES (recon_id_seq.NEXTVAL, dna_host_cur.hostname,
    dna_host_cur.os, dna_host_cur.ip, dna_host_cur.business,
    dna_host_cur.businessunit,
    dna_host_cur.reportingbusinessunit,
    dna_host_cur.userid, dna_host_cur.city,
    dna_host_cur.state, dna_host_cur.country, 'Y', 1,
    SYSDATE, SYSDATE,
    '502061473', SYSDATE
    END IF;
    END IF;
    END LOOP;
    close dna_host;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line ('In Exception step 1 ERROR IS'||SQLCODE||' '||SQLERRM);
    END;
    BEGIN
    DBMS_OUTPUT.put_line ('************Reconciliation step 2******');
    OPEN server_host;
    LOOP
    FETCH server_host INTO server_host_rec;
    EXIT WHEN server_host%NOTFOUND;
    SELECT COUNT (*)
    INTO vserver_cnt
    FROM t_server_defects
    WHERE LOWER (hostname) = LOWER (server_host_rec.hostname);
    IF vserver_cnt > 0
    THEN
    UPDATE t_server_defects
    SET last_found_date = SYSDATE,
    COUNT = COUNT + 1,
    ACTIVE='Y';
    ELSE
    INSERT INTO t_server_defects
    (reconcile_id, hostname, active,
    first_found_date, last_found_date, remediate_date
    VALUES (recon_id_seq.NEXTVAL, server_host_rec.hostname, 'Y',
    SYSDATE, SYSDATE, NULL
    END IF;
    END LOOP;
    CLOSE server_host;
    UPDATE t_server_defects
    SET ACTIVE='N'
    where trunc(last_found_date)<>trunc(sysdate);
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('****Inside exception for step 2******');
    DBMS_OUTPUT.put_line ('ERROR IS'||SQLCODE||' '||SQLERRM);
    END;
    COMMIT;
    END;

  • PLS-00323: subprogram or cursor... really wierd

    I'm not sure where I'm causing this error, here is the pkg spec & body... but if i remove v_end_date from spec & body, then this pkg compiles fine...
    Here is the error message:
    PLS-00323: subprogram or cursor 'my_fn' is
    declared in a package specification and must be defined in the
    package body
    Package Spec
    CREATE OR REPLACE PACKAGE Pkg_Rep IS
    FUNCTION my_fn ( v_app_id IN NUMBER, v_report_no IN NUMBER, v_prop_id IN NUMBER, v_start_dt IN DATE, v_end_dt IN DATE) RETURN number;
    END Pkg_Rep;
    Package Body
    CREATE OR REPLACE PACKAGE BODY Pkg_Rep AS
    FUNCTION my_fn ( v_app_id IN NUMBER, v_report_no IN NUMBER, v_prop_id IN NUMBER, v_start_dt IN DATE, v_end_date IN DATE)
    RETURN number IS
    BEGIN
    END my_fn;
    END Pkg_Rep;
    /

    The signature of the function must be identical, including the name of the parameters.

  • When my screen saver has been on a while, I have to use the cursor to "rub out" part of the screen saver to see my login section. Can anyone help me with this?

    When my screen saver has been on a while, I have to use the cursor to "rub out" part of the screen saver to see my login section. Can anyone help me with this?

    I don't have a solution for you, but just wanted to let you know I used to have the exact same problem. I resolved it (for the most part....about 90% of the time, anyway) by adjusting the screensaver and power settings to never let the computer go to sleep.

  • To more specific class - cursor reference - error 1057

    I must be missing something very stupid here. Why is this cast not working? Thanks!

    There are other questions to be answered:
    1. Does the cursor exist on the graph?
    2. What other errors are you getting earlier in the process?
    3. Have you tried probing the cursor reference before you did the cast to a generic type?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Select cursor reference XY Graph

    Question... I have a XY graph.
    This graph has 3 cursors. Now I want to be able to select cursor 1, 2 or 3. And then edit some property nodes, like line style, width, color.
    How do I do this? Because I can only get 1 cursor reference... that of the active cursor.
    Regards,
    Wouter
    Solved!
    Go to Solution.

    I just ran into the same problem - I'm glad I found this solution.
    Having said that, it's a rather unintuitive way to handle multiple cursor references. This should be improved in a future update.

  • How to get 10 MHz reference clock out of PCI-5922

    Hi,
    I am evaluating PCI-5922 for the my application.
    In my application, PCI-5922 will get signal from agilent 33250 function generator and both instruments will be triggered at the same time with the same trigger signal.
    Is there any way to take out reference clock (10 MHz) out of PCI-5922? If that is possible, synchronizing can be easier.
    I am expecting to have answers from experts!
    Zeehoon
    Solved!
    Go to Solution.

    Hi Zeehoon,
    There are two steps to export the 10MHz reference clock out of the PCI-5922.  
    1)Specify the reference clock source (to use the internal reference select "no source")
    2)Specify the reference clock output (a list of valid terminals can be found in the PCI-5922 Routing Matrix inside the High Speed Digitizers Help)
    Here is a LabVIEW snippet showing the clock exported to PFI 1:
    -Jennifer O.
    Message Edited by Jennifer O on 09-16-2009 04:00 PM
    Attachments:
    ExportReference.JPG ‏11 KB

  • Lightroom CC crashes on startup and "sign out, sign in" solution doesn't work, any other solutions?

    I downloaded LR CC on myMacbookpro and iMac.
    LR5 was installed on both of them previously.
    After installing, LR CC works fine onM Pro, but keeps crashing on iMac.
    I've tried the "sign out, sign in" solution, but never works for me.
    Is there any other solution I can try?
    Since the update, I've edited photos on my 13' M pro instead of 27' iMac and it is getting annoying...

    Did you update to LR 6.0.1 / LR CC 2015.0.1 ?
    <snip>
    von Pete.Green (30. April 2015)
    Today we released an update to Lightroom, Lightroom CC 2015.0.1 (Also, Lightroom 6.0.1) is now available.
    This bug fix addresses issues related to launching Lightroom and accessing online help.
    To Update:
    Choose "Help > Updates" within Lightroom, or click Update from the Creative Cloud desktop application.
    (If you're an early downloader, you may need to restart the CC Desktop application for update to show)
    <snip>

  • How to hide views in a SharePoint2010 list by using out of box solutions only

    Hi,
    I work on a Time Reporting tool which is used by the users to submit their time sheet twice a month.
    The submission of time sheet is done through a MS INFOPATH 2010 form. The data then gets submited to a List named "Time Sheet List".
    This list has several important views already existing. These views had been created by the designer (not me) .
    Currently if an user submits his/her time report once,then they cannot edit/delete it. Only the admins [Me one of them] can do any kind of modifications. 
    I am working on giving the users access to edit/delete their own time report for the current month only.
    I have created a view "Edit Time Sheet" which will show the user only their own time report for the current month only.
    Now the issue is how do i provide permission to the list "Time Sheet List" so that only the "Edit Time Sheet"
    view is visible to the users and the other views are hidden from all users except the admins .
    If i provide edit permission to the whole list then all of the views will become editable which is not wanted.So, i just want the users to see "Edit Time Sheet" view so that they can only modify their own time sheet for
    the curent month.
    Please let me know how i can achieve this through out of box solution as i donot have any dev environment installed in my system. I have only MS INFOPATH2010 and SharePoint Designer 2010 in my system.
    Regards,
    Anena Das

    Hi Anena
    There is no OOTB approach to achieve the same , one simple work around would be
    Edit the view (Site Actions->Edit page) you will see your List view webpart there . Edit the Webpart Properties and Set the "Target Audience". Mention the SharePoint groups in there or users who should view the list view.
    So when a user who is not a part of the target audience navigates to this page , they will not see the list View. You can show some custom message to them "You are not authorized to view this".
    As I mentioned it will be just a work around if u dont want to use Javascript/jQuery and custom components/
    Thanks and Regards,
    Nandini

  • Out of scope error while attaching the attribute set and the operating unit

    Hi,
    Am getting the out of scope error when am trying to attach the attribute set "/oracle/apps/fnd/attributesets/HrOperatingUnits/OperatingUnitName_Transient"
    and the operating unit lov "/oracle/apps/fnd/multiorg/lov/webui/OperatingUnitsLovRN" from my page in JDeveloper.
    Can anyone help?
    Thanks

    Mostly
    It would just be a warning message you can proceed with it there are no issues.But if its an error please do as mentioned by Reetesh.
    Thanks
    AJ

  • HT201077 I shared a photo stream of 174 pictures but only 20 are showing up in the folder that was sent out. Any solutions?

    I shared a photo stream of 174 pictures but only 20 are showing up in the folder that was sent out. Any solutions?
    Help much appreciated!

    Upload to the shared Photo Streams can take a long time. Sometimes hours. Did the photos appear by now in the stream?
    Is the iCloud status o.k. ( iCloud Support webpage)?
    Did you share from your mac or from a mobile device? And where are you checking the stream? On your Mac? If you are uploading from a mobile device - is the battery fully charged? Uploading to the Photo Stream is the first that will be suspended, if the device needs charging.
    have ypu exceeded any limits? Daily hourly upload rates? http://support.apple.com/kb/HT4858
    Regards
    Léonie

  • Can't export web based 'sent' mail out of Network Solutions server

    can't export web based 'sent' mail out of Network Solutions. Inbox and mozilla based sent mail ok. thanks!

    How about asking Network Solutions?

  • I used stationery in mail, but now i want to export that email to pages OR print it out without the email headers printing out.  any solutions?

    i used stationery in mail, but now i want to export that email to pages OR print it out without the email headers printing out.  any solutions?

    Hello carolsuz,
    I was researching ways you might be able to save that email to a picture or export it and found this little gem in the iPhone Users Guide, found here: http://manuals.info.apple.com/en_US/iphone_user_guide.pdf about how to take a screenshot.
    Its on page 12 toward the middle:
    Take a screenshot: Press and release the Sleep/Wake button and the Home button  at the same time. The screenshot is added to your Camera Roll album.
    Take care,
    Sterling

  • Please help out with a solution

    My blackberry curve 9360 gets heated up, the track pad is not functioning properly, gets switched off automatically and gets hanged, Battery drains in less than 5 hours. Once you run any app, it becomes over heated. It started giving me software problems also. After getting it checked at the service centers in Gurgaon they refused to replace the phone and it is not even 1year of its purchase. Please help me out with a solution.
    will be thankful to you

    Hello
    That is most likely a OS issue, especially the first version of OS 7. I faced the same problem with my 9360.
    See this link : http://supportforums.blackberry.com/t5/BlackBerry-Curve/9360-the-official-OS-releases/td-p/1339817
    The above will point you in the right direction as to where to download your OS , as all carriers are listed with a link found at the bottom of the page for instructions on how to reload OS.
    Good luck.

  • Property dataid references object in a scope with shorter lifetime than the

    Hi,
    Can some one help me with this error.
    <h:dataTable value="myBean.list" var="data">
    <h:column>
    <h:outputText rendered="#{data.ok} value="This item is Ok"/>
    </h:column>
    </h:dataTable>
    Error -
    Property dataid references object in a scope with shorter lifetime than the target scope session

    What you have in the faces-config.xml is more important here. It sounds like on of the property of the session bean scope references to the request bean scope bean. This is illegal.
    Sergey : http://jsfTutorials.net

Maybe you are looking for