VARRAYS - how to use in sub procedures and how to empty them?

Hi!
I made a procedure where i use three diffrent varrays. I got it working only after
putting all code in one big MAIN-block. Looks nasty.
If i try to use sub-procedures i allways got ORA-06531-message.
= "Reference to uninitialized collection"
How can i use varrays in sub-procedures? Is there some trick in delcare or in procedure call?
I try to use IN OUT parameters, but i didn't get it working. Run out of time in trial and error, of cource...
I seemed to me that varrays aren't same way usable allover in code as all other variables i have declared.
Is it so?
Now the MAIN-block is long as a year... I'm used to code short MAIN-block with many sub-procedures calls.
(In same procedure, not different procedures in db).
Another problem is how to empty a varray in effective way?
I tried my_varray.DELELTE and my_varray.TRIM but they won't do the thing. These remove/trim the elements but i just need to
empty varray before fetching a new line from db. If I my_varray := NULL; then that same ORA-06531 when next read/write in varray.
Now i just use FOR i IN 1..120 LOOP
my_varray(i) := NULL;
END LOOP;
but there must be better way, hope so.
Cheers,
SL

You were rigth "3360" - i had three varrays too many. Just to the grabage bin and some recoding.
The link you posted show me the way: Associative Arrays
- easy to declare, easy to use, works fine in sub procedures. Great - just what i need.
Thanks alot!
I fully agree W. Robertson on this:
"I often see questions on technical forums about arrays in PL/SQL, which type to use and what the differences are. Although the documentation has quite a lot to say on the subject, I feel it tries to introduce too many concepts at once and ends up being confusing, especially when it comes to choosing between VARRAYs and Nested Table collections, where most of the "which to use" advice is about collection columns of database tables (which you probably don't need), and not about PL/SQL at all."
- sl -

Similar Messages

  • How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader

    Hi,
    How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
    Thanks,
    Vijay V

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Search Segregation - do I have to use a sub-domain and pay for a separate IP address?

    I've got a site that must keep the same domain but has two separate types of visitors (think customers and vendors) is creating a sub-domain and paying for a separate IP address the only way to completely segregate the search results (without going to private login features)?
    I really need to segregate the web content as both customers and vendors have similar questions but the content on their pages aren't helpful to each other. Currently my search results are heavy on Vendor content even when a it is a customer search topic.

    An iCloud email account is accessed with the iPhone's Mail app as an IMAP account. Contacts are synced with the Contacts app on your iPhone, calendar events are synced with the Calendar app, and notes are synced with the Notes app, etc.
    On your desktop, you can add a bookmark with your browser and/or add a webclip to your Desktop for the website if you plan on accessing the account via webmail, or the email account can be created/accessed as an IMAP account with an email client on your computer.

  • HT204053 i am missing pictures on my ipad 2.  i have checked photo stream and camera roll.  actually they were there earlier but now gone.  i also use dropbox as well, and can't find them there either!  Can someone help me figure this out?

    Missing photos from camera roll and photo stream.  i also have been using dropbox.  Will someone tell me how to find them?  they were there yesterday, and i did not delete any?

    Unless someone physically deleted those, you describing practically impossible situation. Even deleting from camera roll would delete from photostream possibly, but not if you manually put those in dropbox and they had time to upload.

  • Start one job after another complets using PL/SQL procedure and DBMS_JOB

    All,
    I am attempting to refresh a materialized view using DBMS_JOB and having a PL/SQL program loop through each materialized view name that resides in a table I created. We do the table because they have to be refreshed in a specific order and I utilize the ORDER_OF_REFRESH column to dictate which MV comes first, second, third, etc.
    Now - I have this working to the extent that it kicks off 4 materialized views (currently set the procedure to only do 4 MVs for testing purposes) but I would ultimately like the procedure to create a new DBMS_JOB that calls DBMS_MVIEW.REFRESH of the next view in line ONLY after the preceeding materialized view DBMS_JOB completes.
    The purpose of all of this is to do a few things. One - if I simply create a procedure with the DBMS_MVIEW.REFRESH call to each materialized view in order - that works but if one fails, the job starts over again and will up to 16 times - BIG PROBLEM. Secondly, we want the job that will call this procedure to fail if it encounters 2 failures on any one materialized view (because some MVs may be dependant upon that data and cannot use old stale data).
    This may not be the "best" approach but I am trying to make the job self-sufficient in that it knows when to fail or not, and doesn't kick off the materialized views jobs all at once (remember - they need to start one after the other - in order).
    As you can see near the bottom, my logic doesn't work quite right. It kicks off all four jobs at once with the date of the whatever LAST_REFRESH is in my cursor (which ultimately is from the prior day. What I would like to happen is this:
    1.) 1st MV kicks off as DBMS_JOB and completes
    2.) 2nd MV kicks off with a start time of 3 seconds after the completion of 1st MV (based off LAST_REFRESH) date.
    3.) This conitnues until all MVs are refresh or until 2 failures are encountered, in which no more jobs are scheduled.
    - Obviously I am having a little bit of trouble with #2 and #3 - any help is appreciated.
    CREATE OR REPLACE PROCEDURE Next_Job_Refresh_Test2 IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_DELIMITER VARCHAR2(1);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH < 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    CURSOR MV_ORDER IS SELECT B.ORDER_OF_REFRESH,
                                  B.MV_OBJECT_NAME,
                                  A.LAST_REFRESH
                             FROM USER_SNAPSHOTS A,
                                  DISCO_MV_REFRESH_ORDER B
                             WHERE A.NAME = B.MV_OBJECT_NAME
                        ORDER BY B.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE + (30/86400); -- Start job one minute after execution time
              ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
         V_FAILURES := 0;
         V_JOB_NO := 0;
         V_NAME := I.MV_OBJECT_NAME;
         V_DELIMITER := '''';
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || V_DELIMITER || V_NAME || V_DELIMITER || ');',V_START_DATE,NULL);
              SELECT JOB, FAILURES INTO V_JOB_NO, V_FAILURES
              FROM USER_JOBS
              WHERE WHAT LIKE '%' || V_NAME || '%'
              AND SCHEMA_USER = 'CATEBS';
    IF V_FAILURES = 3
    THEN DBMS_JOB.BROKEN(V_JOB_NO,TRUE,NULL); EXIT;
    END IF;
    FOR O IN MV_ORDER
    LOOP
    IF I.ORDER_OF_REFRESH > 2
    THEN V_NEXT_DATE:= (O.LAST_REFRESH + (3/86400)); -- Start next materialized view 3 seconds after completion of prior refresh
    END IF;
    END LOOP;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Next_Job_Refresh_Test2;
    ---------------------------------------------------------------------------------------------------------------------

    Justin,
    I think I am getting closer. I have a procedure shown just below this that updates my custom table with information from USER_SNAPSHOTS to reflect the time and status of the refresh completion:
    CREATE OR REPLACE PROCEDURE Upd_Disco_Mv_Refresh_Order_Tbl IS
    V_STATUS VARCHAR2(7);
    V_LAST_REFRESH DATE;
    V_MV_NAME VARCHAR2(30);
    CURSOR MV_LIST IS SELECT DISTINCT NAME, LAST_REFRESH, STATUS
                             FROM USER_SNAPSHOTS
                        WHERE OWNER = 'CATEBS';
    BEGIN
    FOR I IN MV_LIST
    LOOP
         V_STATUS := I.STATUS;
         V_LAST_REFRESH := I.LAST_REFRESH;
         V_MV_NAME := I.NAME;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.LAST_REFRESH = V_LAST_REFRESH
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.REFRESH_STATUS = V_STATUS
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    END LOOP;
    END Upd_Disco_Mv_Refresh_Order_Tbl;
    Next, I have a "new" procedure that does the job creation and refresh show just below this which, when starting the loop, sets the LAST_REFRESH date in my table to NULL and the STATUS = 'INVALID'. Then if the order of refresh = 1 then it uses SYSDATE to submit the job and start right away, else if it's not the first job, it uses V_NEXT_DATE. Now, V_NEXT_DATE is equal to the LAST_REFRESH date from my table when the view has completed and the V_PREV_STATUS = 'VALID'. I think tack on 2 seconds to that to begin my next job.... See code below:
    CREATE OR REPLACE PROCEDURE Disco_Mv_Refresh IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_PREV_STATUS VARCHAR2(7);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME,
                                  A.LAST_REFRESH,
                                  A.REFRESH_STATUS
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH <= 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    V_NAME := I.MV_OBJECT_NAME;
    V_FAILURES := 0;
    UPDATE DISCO_MV_REFRESH_ORDER SET LAST_REFRESH = NULL WHERE MV_OBJECT_NAME = V_NAME;
    UPDATE DISCO_MV_REFRESH_ORDER SET REFRESH_STATUS = 'INVALID' WHERE MV_OBJECT_NAME = V_NAME;
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE;
    ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || '''' || V_NAME || '''' || '); BEGIN UPD_DISCO_MV_REFRESH_ORDER_TBL; END;',V_START_DATE,NULL);
    SELECT A.REFRESH_STATUS, A.LAST_REFRESH INTO V_PREV_STATUS, V_NEXT_DATE
    FROM DISCO_MV_REFRESH_ORDER A
    WHERE (I.ORDER_OF_REFRESH - 1) = A.ORDER_OF_REFRESH;
    IF I.ORDER_OF_REFRESH > 1 AND V_PREV_STATUS = 'VALID'
    THEN V_NEXT_DATE := V_NEXT_DATE + (2/86400);
    ELSE V_NEXT_DATE := NULL;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Disco_Mv_Refresh;
    My problem is that it doesn't appear to be looping to the next job. It worked succesfully on the first job but not the subsequent jobs (or materialized views in this case).... Any ideas?

  • Using PL/SQL procedure and function

    In a page i have a VO that uses a Where clause that looks like this
    WHERE attr=package.function
    where the function returns a value of an internal variable valued by another procedure in the package which considers only the Dbuser DBSchema as parameters.
    Do i have to call the procedure in a method like initializeBindigsForPage or i have to put it in another place? And in which mode?
    Thanks Marco

    hi satish,
    i tried ur suggestion, but its shows error like
    declare
    o1 number;
    total_bytes number;
    o3 number;
    unused_bytes number;
    o5 number;
    o6 number;
    o7 number;
    b number:=0;
    str varchar2(2000);
    cursor name is select TNAME FROM TAB WHERE TABTYPE='TABLE';
    begin
    FOR VAL IN name
    LOOP
    DBMS_SPACE.UNUSED_SPACE('XMLUSER',VAL.TNAME,'TABLE',o1,total_bytes,o3,unused_bytes,o5,o6,o7);
    --dbms_output.put_line(VAL.TNAME);
    --dbms_output.put_line(total_bytes);
    --dbms_output.put_line(unused_bytes);
    EXECUTE IMMEDIATE 'select count(*) from '||VAL.TNAME||' ' RETURNING into b;
    --select count(*) into b from VAL.TNAME;
    --execute immediate(str);
    dbms_output.put_line(b);
    insert into space values(VAL.TNAME,total_bytes,unused_bytes,b);
    END LOOP;
    end;
    SQL> @space.sql
    declare
    ERROR at line 1:
    ORA-06547: RETURNING clause must be used with INSERT, UPDATE, or DELETE
    statements
    ORA-06512: at line 19
    wat goes wrong satish?

  • Trash thinks files are in use and can't empty them

    I was cleaning up some old files today. I had the System folder from an OLD Quadra 610 archived and made it a disk image. I threw the originals in the trash and now these items (all extensions) cannot be removed:
    Disinfectant INIT (extension from MacLink Plus)
    Apple Built-In Ethernet
    Apple Ethernet NB
    Apple Token Ring NB
    The system thinks they are in use. They are not locked. I tried dragging them out for a rename and they remain in the trash. When I put the new files back in the trash I ended up with three copies of all the files. One problem is that when I was archiving them (some years ago), I put the System Folder in a folder called "System" and now I think the current System sees a conflict. Note: the original files were on a back up drive WITHOUT an OS X system on it. How can I get rid of these files?
    G5 dual 2.7   Mac OS X (10.4.8)  

    Thanks for the response. Unfortunately, the link does not solve the problem because I can move the offending folder to the desktop but it does not leave the trash.
    I really think it is because I have a folder named "System" in the trash, which was generated way before OS X came out (these were archived files). It is strange, many of the files were deleted fine when empting the Trash except the four mentioned above. I tried a safe boot but it did not work.
    G5 Dual 2.7   Mac OS X (10.4.8)  

  • I downloaded (11) ringtones yesterday on my iPad using a gift card and I cannot find them anywhere.

    I downloaded (11) ringtones from iTunes yesterday from my iPad and cannot find them anywhere.  I even assigned each ringtone to an individual in my contact file.  When I sign into iTunes on my PC, it shows that I used all but .81 of my gift card that I used to purchase the ringtones, but under the "Purchased" tab, It's not showing anything.  It's also not showing anything purchased in my "Library".

    Try restarting the iPad (the red "swipe to power off", then power back on). That may get the movie to appear in the Videos app. If not, go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Can i use Stored procedures and triggers with SDK

    hi all
    How to use the stored procedure and Triggers with SDK, can i get a sample code
    Regards
    Salah

    Hi, Salah.
    Use "Exec" in your query to run procedures.
    SAPbobsCOM.Recordset     oRS;
    oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
    oRS.DoQuery ("EXEC YourStoredProcName");
    Triggers are not supported in SDK.
    Regards,
    Aleksey

  • Java stored procedures and triggers in lite

    Hi
    We are using java stored procedures and java triggers in our application for oracle lite database 5.1.
    We would like to know whether these procedures and triggers are uploaded or associated with tables or not because triggers are not being fired for the tables.
    The question is - how to find the uploaded procedures and triggers in system tables.
    We dont find any tables like (all_objects, user_objects) for this in oracle lite system catalogs given in the documentation.
    thanks in advance
    yugandhar

    I don't have much experience with Lite, but I'm running 9i Personal Edition. Any information about triggers can be found in the "ALL_TRIGGERS" view. You will want to filter out any rows where OWNER = 'SYS' unless you created your triggers as SYS. As for procedures and functions, you can see what you have created in the "ALL_OBJECTS" view where OBJECT_TYPE = 'PROCEDURE' or 'FUNCTION', once again filtering out rows where OWNER = 'SYS'. To see the code of any procedure or function, select substr(text,1,80) from ALL_SOURCE where NAME = 'function name' ORDER BY LINE.
    Hope this helps!

  • Java Stored Procedures and Triggers

    I want to to use Java stored procedures and triggers within the Oracle 11g XE
    So please , someone can help me because i tried but it didn't work
    I don't know where is the problem
    Thanks !!

    WRONG FORUM!
    Welcome to the forum but this forum is for Java JDBC questions and issues. Your question should be posted in the SQL and PL/SQL forum
    PL/SQL
    >
    I want to to use Java stored procedures and triggers within the Oracle 11g XE
    So please , someone can help me because i tried but it didn't work
    I don't know where is the problem
    >
    Mark this question ANSWERED and repost the question in the other forum
    Before you post review the Oracle Database Java Developer's Guide - it shows how to create Java stored procedures and has example code
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    And in the new post don't just say "I tried but it didn't work". You need to post the code that you tried and what you mean by "didn't work".
    If you got any exceptions or errors you need to post a copy of the exact message or error that you are getting.

  • Beans using plsql stored procedures

    Hi all
    My question is: has jdeveloper any graphic tool or asistant to make something like use stored procedures that return multiple rows ( ref cursor ).
    This is my problem, i'm student and have to build a web project that use beans, stored procedures and webservice.... i'm total noob in ejb, but i had worked with plsql some time.
    Can anyone tell me pls where to start, some article to read or something that may help me in this task
    Victor

    A Ref Cursor doesn't have any implicit structure, so it's not easy to automatically bind bean to it, however if you create database types like this, for example:
    drop type dept_t_list;
    drop type dept_t;
    drop type emp_t_list;
    drop type emp_t;
    create type emp_t as object(
      empno number(4),
      ename varchar2(10),
      job varchar2(9),
      mgr number(4),
      hiredate date,
      sal number(7,2),
      comm number(7,2),
      deptno number(2),
      terminated varchar(1)
    create type emp_t_list as table of emp_t;
    create type dept_t as object(
      deptno number(2),
      dname varchar2(14),
      loc varchar2(13),
      emps emp_t_list
    create type dept_t_list as table of dept_t;
    /Then you can create a pl/sql store procedure that works with this types and list types easily as beans and arrays of beans using the JPublisher tool.
    If you visit my Not Yet Documented Examples page and see example 36, it contains the SQL scripts that create example types and a stored package to work with them. It also contains the JPublisher-created Java classes for working with those types and package.
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    Inside JDeveloper, if you visit the connection navigator, expand your database connection and expand the "Packages" node, you can right-mouse and generate java (using JPublisher under the covers for you) on any package.

  • HT3500 I keep getting an error message that the "spools are full".  How do I access the spools and how do I empty them?

    I keep getting an error message that the "spools are full". Where do I find them and how to empty them?

    You may be able to determine the reason for this error by examining your Mac's logs with Console. To do that find the Console app - it is in your Utilities folder and looks like this
    You can find it by selecting Utilities from the Finder's Go menu.
    Open Console.
    If the log list column on the left is not already displayed, show the log list by selecting Show Log List from Console's View menu.
    Locate system.log in the list and select it. Many date and time-stamped entries will appear, hundreds of them, and you must find the entries relevant to your Mac's problem. To do that choose Clear Display from Console's toolbar. Leave Console running while you choose Print from iPhoto again. Examine any new entries logged in Console. If there are any, copy and paste them in a reply.

  • How to create a stored procedure and use it in Crystal reports

    Hi All,
    Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
    Thanks in advance.

    If you are using MSSQL SERVER then try creating a stored procedure like this
    create proc Name
    select * from Table
    by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
    here is the syntax to create SP
    Syntax
    CREATE PROC [ EDURE ] procedure_name [ ; number ]
        [ { @parameter data_type }
            [ VARYING ] [ = default ] [ OUTPUT ]
        ] [ ,...n ]
    [ WITH
        { RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
    [ FOR REPLICATION ]
    AS sql_statement [ ...n ]
    Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
    Regards,
    Raghavendra
    Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM

  • How to create stored procedures and use those in Crystal reports

    Hi All,
    Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
    Thanks in advance.

    Hello,
    There is a document explainining how to use Oracle stored proc with Crystal reports.
    Check at:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253
    It is for older version but it should work and you can refer to it to get general idea how to start with it. It has a sample oracle stored proc and how to connect it from Crystal Reports.

Maybe you are looking for

  • 2nd fax won't work at Laserjet Pro 400 MFP M425DN

    I have recently bought the HP Laserjet Pro 400 MFP M425DN, which is working almost fine. The problem is when i do want to send a fax, it will send it, but after that the second fax won't be able to send. I just get the message 'communication error'. 

  • Forms 10.1.2 - Imported Java Classes are not running on JNI.NEW_OBJECT call

    Hi All, I've created a java class to call a webservice. This has been developed and tested in JDeveloper and works ok (using JDev Wizards - so it's generated code). I've created the JAR from it, imported the classes into Forms Builder and have my pac

  • BI : Vendor Master

    Hi Experts, would like to know a few things. Kindly advise. We are doing the extraction from R3 for 0vendor_attr & 0vendor_txt. I have created the respective transformations & DTP in our *BI production system*. but when i executed the infopackagesi f

  • AD RMS 2012 IRM permissions for SharePoint 2013 Library

    Hello guys Please, someone knows a technet document about IRM permissions for SharePoint 2013 Library, specifically? thanks a lot. Edward

  • Nvidia Display Driver Error on Bootup

    Hello all, I installed Boot Camp 3.1 and when I rebooted, after logging in on my windows drive, I get 2 display error pop-ups before my desktop appears. I uninstalled all the display drivers manually, used a driver cleaner, and reinstalled the Nvidia