collection vs sys_refcursor parameter

When it provides a set of results in a function parameter, are there advantages/disadvantages to using a sys_refcursor vs collection type a user defined?

>
I proposed an iteration through the game of results that foo() returns and then return pipelined (sorry, should have made clear that) the lines of a collection, which is a function of adapter that would take the ref cursor and return a "table" can be reached. So instead of taking a p_deptno, as in your example, the adapter function would take the ref cursor returned by foo() as a parameter and then loop through it every record out of pipes. Is this the best approach?
>
This is the ONLY approach that you will be able to use.

BluShadow wrote a final piece that covers ALL of the options. Towards the end of the second page is an example in pipeline similar to what you ask in the topic.
PL/SQL 101: Understand the Ref Cursor

Tags: Database

Similar Questions

  • Collection as a parameter in the function - help needed

    I have a function that returns 3 different values according to a given in parameter.
    Now, I want to return these three values.
    Instead of using three out parameters, how can I use a collection for return values.

    Please tell me the best way that returning multiple values (more than 3)

    Thanks in advance

    Concerning
    Rambeau
    SQL> create type my_obj as object (no integer, name varchar2(10))
      2  /
    
    Type created.
    
    SQL> create type my_tbl as table of my_obj
      2  /
    
    Type created.
    

    functional approach...

    SQL> create or replace function my_fn return my_tbl
      2  as
      3     ltbl my_tbl;
      4  begin
      5     select my_obj(1,'karthick') bulk collect into ltbl from dual;
      6
      7     return ltbl;
      8  end;
      9  /
    
    Function created.
    
    SQL> select * from table(cast(my_fn() as my_tbl))
      2  /
    
            NO NAME
    ---------- ----------
             1 karthick
    

    procedureal approach...

    SQL> create or replace procedure my_proc(ptbl out my_tbl)
      2  as
      3  begin
      4     select my_obj(1,'karthick') bulk collect into ptbl from dual;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> declare
      2     ltbl my_tbl;
      3  begin
      4     my_proc(ltbl);
      5
      6     for i in 1..ltbl.count
      7     loop
      8             dbms_output.put_line(ltbl(i).no||'      '||ltbl(i).name);
      9     end loop;
     10  end;
     11  /
    1       karthick
    
    PL/SQL procedure successfully completed.
    
  • Procedure with the collection as a parameter-help needed

    I have records like below:

    Add time of Rol
    ---------------
    A1 08:20
    A2 08:25
    A2 A1 08:29
    A2 A1 08:32
    A3 08:45
    A3 08:46
    A3 08:50

    I have a scenario where I have to calculate the average_time based on a scenario.
    The formulas that we have to calculate the average is:
    (min (next_address) - max (previous_address)) * 0.55
    that is, for example, form 5, (08:45 - 08:32) * 0.55.
    Here in my procedure I am passing the TDA and Rol as input parameters collection.
    How can I go and calculate the value of average_time is now.

    I tried with
    For I in Add.count
    loop
    v_avg_time: = (Add(I+1) - Add (I)) * 0.55;
    end loop;

    When I want to test this, I am not knowing how to pass values to the procedure.
    Please tell me how to run the procedure and how to get the results.

    Thanks in advance

    Concerning
    Rambeau

    Try like this.

    SQL> create or replace type my_num as table of number
      2  /
    
    Type created.
    
    SQL> create or replace procedure my_proc (pNum my_num)
      2  as
      3     lsum number;
      4     lavg number;
      5  begin
      6     select sum(column_value), avg(column_value)
      7       into lsum, lavg
      8       from table(cast(pNum as my_num));
      9
     10     dbms_output.put_line('SUM: ' ||lSum);
     11     dbms_output.put_line('AVG: ' ||lAvg);
     12  end;
     13  /
    
    Procedure created.
    
    SQL> declare
      2     lNum my_num := my_num(1,2,3,4,5,6,7,8,9,10);
      3  begin
      4     my_proc(lNum);
      5  end;
      6  /
    SUM: 55
    AVG: 5.5
    
    PL/SQL procedure successfully completed.
    

    Thank you
    knani.

  • The shift from collection to function error

    Hello world.  I am a novice in PL/SQL and I get an error and I don't know why.  Here is my code.

    FUNCTION validate_column(
        in_columns IN CHAR_TBL,
        in_column_str IN VARCHAR2)
    RETURN VARCHAR2
    AS
        avail INT := 0;
    BEGIN
        SELECT COUNT(*) INTO avail FROM in_columns WHERE column_name = UPPER(in_column_str);
    RETURN '';
    END validate_column;
    
    
    
    FUNCTION test(
        in_table IN VARCHAR2)
    RETURN VARCHAR2
    AS
      COLS CHAR_TBL;
    BEGIN
        SELECT column_name BULK COLLECT INTO COLS FROM user_tab_columns WHERE table_name = in_table;
        validate_column(COLS, 'abc');
        RETURN '';
    END test;
    

    CREATE OR REPLACE TYPE CHAR_TBL
    AS
      TABLE OF VARCHAR2(4000);
    

    When I compile this code, I get an error on line 7 above.  ORA-00942: table or view does not exist.

    NOTE: user_tab_columns is integrated oracle table.

    What I am doing wrong?  I am not able to pass a collection as a parameter to a function?

    Thank you

    There are quite a few errors, see the example below:

    CREATE OR REPLACE TYPE CHAR_TBL

    AS

    TABLE OF THE VARCHAR2 (4000);

    /

    (Validate_column) CREATE or REPLACE FUNCTION

    in_columns IN CHAR_TBL,

    in_column_str IN VARCHAR2)

    RETURN NUMBER

    AS

    avail INT: = 0;

    BEGIN

    COUNT (*) of SELECT INTO TABLE OF (in_columns) WHERE COLUMN_VALUE available = UPPER (in_column_str);

    RETURN nothing.

    END validate_column;

    /

    CREATE or REPLACE the FUNCTION test)

    in_table IN VARCHAR2)

    RETURN NUMBER

    AS

    PASSES CHAR_TBL.

    v_cnt NUMBER;

    BEGIN

    SELECT column_name BULK COLLECT INTO PASSES FROM user_tab_columns WHERE table_name = in_table;

    v_cnt: = validate_column (PASSES, 'abc');

    RETURN v_cnt;

    END test;

    /

  • Appeal procedure in another procedure using the Out parameter slider - lesson

    Hello

    I am new to Oracle development so first I wonder if it is a good place with a simple way of the of on how to create stored procedures?  I'm looking for the most part at this stage for a quick read.

    Second, currently have hacked and slashed my way into getting one built.  It has 3 parameters and an output parameter sys_refcursor.  This procedure works.

    I want to have another created procedure that will call the above procedure and loop through each row in the setting out and write to a file.  Can someone point me to an example of this by any chance?

    Thanks for the help.

    Hello

    e28d78d3-c6c6-4BCE-b14f-0f6bf26fa17c wrote:

    Thanks for the reply.

    Here's what I have, but I'm getting many errors.  When I seem to fix one that I get a new one. Kind of like what it show me all questions vs one question at a time.  I never know if I create another error of my attempts at fixing what, in my view, could be the problem.  In any case, something to get used to.

    When you do any type of programming, take baby steps.  Write less code as possible, test what you wrote ' worm and, if it contains errors, correct them and test again.

    The PL/SQL compiler tries to show all errors, but often it is impossible to say what is a separate mistake, and which is a consequence of a previous error.  For example, the DECLARE statements in your code are perfectly valid PL/SQL statements, but they are the mistakes in the sense that they are not what you think, and you may not use them.  PL/SQL does not know that (I don't really know that, either, but I'm willing to guess in this case).  The works of compiler on the explanation that you really wanted to say SAID, until what it becomes obvious, maybe several lines later, that something makes no sense, but at this time, there is no way he could say that the undesirable DECLARE was the cause.

    So here is where I am stuck currently.  What I want should first, run the stored procedure and I think I do as you suggest.  Which returns data in the output parameter, which is of type sys_refcursor.  I think I would need to loop through each element that cursor and output to the file using the dbms_output you reference and like I did below.  This should be it.  Sounds simple enough, but it's where some of the basics for me.

    For example, by creating the procedure some examples have the name of the procedure and then some "AS", "IS".  When use the beginning and the end and when not I need?

    There is no difference betwwen

    CREATE PROCEDURE... AS and

    CREATE PROCEDURE... Use IS the one you prefer.  You must always one or the other, however.

    PL/SQL is written in blocks.  The basic structure of a block is

    DECLARE - optional, sometimes involved

    ...

    BEGIN

    ...

    -Optional EXCEPTION; forget it for now

    ...

    END;

    Almost all of the PL/SQL code is part of a block.  In fact, you could argue that anything not in a block isn't really PL/SQL.  (For example, CREATE PROCEDURE is really an SQL, PL/SQL not, it indicates the SQL that some PL/SQL compiler is coming.)

    You should always BEGIN and END keywords in a PL/SQL block; None is never optional.

    I think I'm doing the for loop correctly but I get an error on the portion of loop-end.  It is a part of these simple things that become I think that.

    That's what I have:

    CREATE OR REPLACE PROCEDURE APPS.boact_report_3

    AS

    DECLARE v_cur SYS_REFCURSOR;

    DECLARE v_file_out UTL_FILE.file_type;

    BEGIN

    I said earlier, DECLARED may be implied.  It's one of those places if there is nothing after CREATE PROCEDURE... IS and before STARTING, it is supposed to be a statement.

    You can have as many statements (0, 1, 2 or more) that you want in this section of the statement.  The semicolon at the end of each of them is all the separation you need each other; you don't need any keyword as STATED.

    Open the v_cur for

    bo_report (p_sv_id, p_start_date, p_end_date, out v_cur);  -stored procedure that girls v_cur witch is a sys_refcursor parameter.  It works

    END;

    BEGIN

    Don't forget, how to call a procedure is

    bo_report (x, y, z);

    not

    bo_report (x, y, z OUT);

    The key words are only necessary (and only used) in the declaration of a procedure, not in his appeal.  When you create a procedure, you decide if each argument is going to be an argument IN, an OUT argument, or IN OUT argument, and you tell the compiler that you decide.  When you call a procedure, you have no choice; each argument is IN, OUT or IN OUT has already been decided, and suffice to say compiling what are the variables (or expressions) that you use to play these predetermined roles.

    Dbms_output.put_line ('Date: ');

    v_file_out: =.

    UTL_FILE.fopen (' / public/scripts/smorau02 ', 'w_act.csv', 'W');

    FOR x IN v_cur

    LOOP

    () UTL_FILE.put_line

    v_file_out,

    x.cl_num | ','

    || x.wa_id | ','

    || x.Description | ','

    || x.a_date | ','

    || x.a_by | ','

    || x.v_Name | ','

    || x.SITE_NAME | ','

    || x.stage | ','

    || x.in_queue);

    END LOOP;

    UTL_FILE.fclose (v_file_out);

    END;

    Thanks again for the help.

    You have not to send the code to bo_report, so I can't run the procedure.  I do not notice any obvious mistakes immediately superior.

  • Doubt about the passage collection (Pl/SQL table) in a procedure.

    Hi all

    I have developed a package of sample with procedure 1. Here, I spent the output to a table in the collection data and I am passing the array of the collection as a parameter out.
    When I run the proc, it worked for 1 scenario, but did not work for the other. I posted two scenarios after the code.
    pkg spec:
    
    create or replace
    PACKAGE IMP_EXP_BKUP_PKG
    AS
      TYPE test10_tbl2 IS TABLE OF test10.t1%type INDEX BY BINARY_INTEGER;
      v2_test10 test10_tbl2;
      PROCEDURE manpower_list(v1 number, v2 out test10_tbl2);
    END IMP_EXP_BKUP_PKG;
    
    Pkg Body:
    
    create or replace
    PACKAGE BODY IMP_EXP_BKUP_PKG 
    AS 
    PROCEDURE manpower_list(v1 number, v2 out test10_tbl2)  AS
    BEGIN
      SELECT t1 BULK COLLECT INTO v2 FROM test10 WHERE t4 = v1; 
    END;
    END IMP_EXP_BKUP_PKG;
    Scenario 1:
    DECLARE
      v2 imp_exp_bkup_pkg.test10_tbl2;
    BEGIN
      imp_exp_bkup_pkg.manpower_list('10', v2);
      FOR i IN v2.FIRST..v2.LAST
      LOOP
        DBMS_OUTPUT.PUT_LINE(v2(i));
      END LOOP;
    END;
    Worked well.

    Scenario 2:
    DECLARE
      --v2 imp_exp_bkup_pkg.test10_tbl2;
      TYPE typ_tbl2 IS TABLE OF test10.t1%type INDEX BY BINARY_INTEGER;
      v2 typ_tbl2;
    BEGIN
      imp_exp_bkup_pkg.manpower_list('10', v2);
      FOR i IN v2.FIRST..v2.LAST
      LOOP
        DBMS_OUTPUT.PUT_LINE(v2(i));
      END LOOP;
    END;
    
    Error:
    ORA-06550: line 6, column 3:
    PLS-00306: wrong number or types of arguments in call to 'MANPOWER_LIST'
    Is not here.

    I want to just make sure that, are we supposed to use the same type that we have breeding stock in the package for the declaration of the variables?

    SamFisher wrote:

    I want to just make sure that, are we supposed to use the same type that we have breeding stock in the package for the declaration of the variables?

    Yes, you MUST use the same type definition.

    SY.

  • Questions about apex_web_service.make_request and collections

    Hello

    I began using with Apex Web services, and I have a few questions about the apex_web_service.make_request procedure. You can pass a name of the collection as a parameter. I'm a little confused on this parameter from the collection...

    This is perhaps a silly question, but the documentation is not very clear, so... This procedure always inserts just a line in the collection (with the XML returned by the web service call), or are there cases where several lines will be inserted?

    If there is still only a single row, what are the practical reasons to use a collection for her? I ask because in most cases interest you about the columns/rows to display in a form or a report in the Apex and I don't see the advantage to store in a collection of single-row, but I may be missing something...

    If the response contains several rows of data, it will be automatically extract the lines and insert them into the different lines of the collection? (posts...)

    What is the best approach then to extract several rows returned in the XML response and insert them into a collection? Currently I use XMLTABLE in a loop and call apex_collection.add_member for each row returned. is there a better way to do it?

    Thank you
    Luis

    Luis,

    the webservice returns only one row in the results collection.

    XMLTABLE using is a good idea, instead of using a loop, you can also use APEX_COLLECTION. CREATE_COLLECTION_FROM_QUERY or CREATE_COLLECTION_FROM_QUERY_B (B for bulk which may mean 'fast').

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • access a type of user to another schema (collection)

    Hello

    In my scheme of production, I created a user type:
    CREATE TYPE T_my_row  OID '4711'
    IS OBJECT(field1 varchar2(10), field2 number(10));
    /
    
    CREATE TYPE TT_my_table  OID '0815'
    IS TABLE OF T_my_row;
    /
    I use the TT_my_table collection as a parameter of a procedure type.

    Intended to test, I would like to call this procedure from another schema (SQL-developers UT repository). This is why I need 'access' to the collection type of this test pattern.

    What are the rights I give to achieve?

    Good bye
    DPT

    Edited by: T.PD the 29.06.2010 10:40

    Dear T.PD,

    I think that under query will work for you;

    SQL > GRANT EXECUTE, DEBUG ON TYPE_NAME TO SCHEMA_NAME.

    It will be useful,

    Ogan

  • using the collection as an array

    Hello
    I want to use a collection as a Table.Can someone give me a code for this example.

    I'm a collection to the parameter and want to join another collection that lines with another table. I want that, because if I'm going to do the operation loop taking elements one by one and in comparison with the record in the DB table, the performance should be degraded.

    Please give the solution for the use of a collection in a table to join with another table.

    Thanks in advance
    Guljeet

    Hello

    You can find examples by doing a search on this forum or on AskTom.
    See fi.:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:666224436920

  • Working with table gross typed the parameter of the procedure.

    I have a table defined as


    CREATE TABLE 'JOBS '.
    ("JOB_ID' VARCHAR2 (200 BYTE),
    'FUNCTION' RAW (16).
    NUMBER OF "MIN_SALARY."
    NUMBER OF "MAX_SALARY.
    )



    Defined as package

    create or replace package associative_array as
    type t_job_id is table of index jobs.job_id%type by pls_integer;
    type t_job_title is table of index jobs.job_title%type by pls_integer;
    type t_min_salary is table of index jobs.min_salary%type by pls_integer;
    type t_max_salary is table of index jobs.max_salary%type by pls_integer;

    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary to t_max_salary);
    end associative_array;
    /


    create or replace package body associative_array as
    procedure array_insert (p_job_id in t_job_id,
    p_job_title in t_job_title,
    p_min_salary in t_min_salary,
    p_max_salary to t_max_salary) is
    Start
    ForAll i in p_job_id.first... p_job_id. Last
    insert into jobs (job_id,
    function,
    min_salary,
    max_salary)
    values (p_job_id (i),
    p_job_title (i),
    p_min_salary (i),
    p_max_salary (i));
    end array_insert;
    end associative_array;
    /

    The client code is

    String s = "UserID = system; password = system; data source = ORCL; enlist = true; layout common = true ";

    create and open the connection object
    Con OracleConnection = new OracleConnection (constr.);
    con. Open();
    OracleCommand cmd = con. CreateCommand();
    cmd.CommandText = "associative_array.array_insert";
    cmd.CommandType = CommandType.StoredProcedure;

    create objects for each parameter setting
    OracleParameter p_job_id = new OracleParameter();
    OracleParameter p_job_title = new OracleParameter();
    OracleParameter p_min_salary = new OracleParameter();
    OracleParameter p_max_salary = new OracleParameter();

    set the type parameter for each parameter
    p_job_id. OracleDbType is OracleDbType.Varchar2.;
    p_job_title. OracleDbType = OracleDbType.Raw;
    p_min_salary. OracleDbType = OracleDbType.Decimal;
    p_max_salary. OracleDbType = OracleDbType.Decimal;

    Set the type of collection for each parameter
    p_job_id CollectionType in the Group OracleCollectionType.PLSQLAssociativeArray;
    p_job_title. CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p_min_salary. CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p_max_salary. CollectionType = OracleCollectionType.PLSQLAssociativeArray;

    Set the parameter values
    p_job_id. value = new string [3] {"IT_DBA", "IT_MAN", "IT_VP"};
    p_job_title. Value = new Guid [1] {Guid.NewGuid ()};
    p_min_salary. Value = new decimal [3] {8000, 12000, 18000};
    p_max_salary. Value = new decimal [3] {16000, 24000, 36000};

    set the size for each table
    p_job_id. size = 3;
    p_job_title. Size = 1;
    p_min_salary. Size = 3;
    p_max_salary. Size = 3;

    p_job_id. ParameterName = "p_job_id";
    p_min_salary. ParameterName = "p_min_salary";
    p_max_salary. ParameterName = "p_max_salary";
    p_job_title. ParameterName = "p_job_title";

    Add parameters to the collection of command objects
    cmd. Parameters.Add (p_job_id);
    cmd. Parameters.Add (p_job_title);
    cmd. Parameters.Add (p_min_salary);
    cmd. Parameters.Add (p_max_salary);

    BindByName. cmd = true;
    run the insert
    cmd ExecuteNonQuery());

    Error occurred during execution of the customer.

    Unhandled exception: System.ArgumentException: invalid parameter binding
    Parameter name: p_job_title
    at Oracle.DataAccess.Client.OracleParameter.GetBindingSize_Raw (Int32 idx)
    at Oracle.DataAccess.Client.OracleParameter.PreBind_Raw)
    to Oracle.DataAccess.Client.OracleParameter.PreBind (OracleConnection conn, IntPtr errCtx, Int32 arraySize)
    at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery)

    But if I change jobs. P_job_title varchar2 and change function. Value and p_job_title. Therefore, any OracleDbType is fine.

    Following me is at fault-
    p_job_title. Value = new Guid [1] {Guid.NewGuid ()};

    Since you have already said-
    p_job_title. OracleDbType = OracleDbType.Raw;

    You must have 'p_job_title. Value' as 'Byte' or 'OracleBinary.

    It will be useful.

  • Error-307650 during a sequence in real-time with API LV

    I created a basic real-time sequence that checks the time it takes a signal reach a certain threshold.

    On the side of the LV, I use the API to call this sequence. I make sure that all channels and settings are defined as in the examples. However I get 307650 error that says "NEITHER VeriStand: Index was out of range." Must be non-negative and less than the size of the collection.

    ' Parameter name: index.

    Any suggestion to help here? THX. Code is attached.

    There are two problems here:

    1. The Stimulus profile editor is not indicating that there is an error with this sequence, although there is a. Note that the variable InitialTime is used in an expression, but is not declared as a parameter or a local variable.

    2. you get an error at runtime because of it, but it's not terribly useful (index out of range).

    You can fix this by adding a local variable of InitialTime to your sequence. I dropped the CAR 338386 about this bug.

    Once you do this, there is something extra, you will need to set in your VI which runs the sequence so he could get the results of the sequence properly. You use correctly the value of the sequence name to read the back of the sequence Variable. You use the Session name used during the deployment of the sequence. Which does not match the name sequence.

    To get the name of the sequence, use VI to get all the names sequence on your session profile of stimulus to get the array of names for all of the top level of the session sequences, then index on the first point, given that you only use a single sequence. Example below:

  • Disable slide horizontal, the top menu and scrubber?

    This default Adobe navigation can be great for some applications, but not mine. Indeed, it makes navigation more confusing since I was a dedicated exit the menu for my navigation app.

    Is there some way to disables the default / built by striking horizontal swipe, top menu and scrubber? Thank you, thank you.

    There isn't a way to disable it. There are a few hacks involving overlays full HTML screen, but that will not interfere with your sliding menu.

    In 2015, DPS, you can disable the horizontal navigation within a collection using a parameter on the collection, but you will always get the top to the top menu when the reader clicks on the page. There is no Purifier DPS in 2015.

    Neil

  • ORA 22813 in the merge statement

    Hi the gems... Good afternoon...

    My version of the database is 11.2.0.1.0 Solaris 64-bit OS.

    I am facing a ' ORA-22813: value of the operand exceeds the limits of the system "during the execution of a procedure.
    I used loggers and found that it is getting failed in a MERGE statement.

    This merge statement is used to merge a table with a collection. the code is as below:
    MERGE /*+ INDEX(P BALANCE_HISTORIC_INDEX) */
        INTO BALANCE_HOLD_HISTORIC P
        USING TABLE(GET_BALANCE_HIST(V_MERGE_REC)) M
        ON (P.CUSTOMER_ID = M.CUSTOMER_ID AND P.BOOK_ID = M.BOOK_ID AND P.PRODUCT_ID = M.PRODUCT_ID AND P.SUB_BOOK_ID = M.SUB_BOOK_ID AND)
        WHEN MATCHED THEN
          UPDATE
             <set .....>
        WHEN NOT MATCHED THEN
          INSERT<.....>
    Function GET_BALANCE_HIST (V_MERGE_REC) parameter is an array type.
    Now GET_BALANCE_HIST (V_MERGE_REC) is a function in the pipeline and we used that because the V_MERGE_REC collection can become huge with data.

    This process worked very well since the beginning, but since yesterday, it was constantly throwing 22813 ORA error in this line.

    Help, please... Thanks in advance...

    Gogol wrote:
    The code flow is as below:

    There is a sql query, the output is a set of some several lakes of records. Now we take the result of the sql query in a collection with a limit of 1000 (FETCH cur_sql COLLECT LOOSE v_balance_rec LIMIT 1000). Then we do a lot of processing, the calculation of this collection.

    After the treatment and calculation, we are filling another collection this collection transformed (V_BALANCE_REC) (V_MERGE_REC). Thus, if the loop iterates for 1000 times, then the V_MERGE_REC is filled with records of 1000 * 500 = 500000 processed.

    And then we go to this huge V_MERGE_REC collection as a parameter to this function.

    Don't know what are the Lakes. Please use International English.

    Why can't do you math in a SQL query?

    If it's really too hard to do in SQL (SQL queries can perform a treatment fairly complex), then I would look to Scripture
    results of a table and use it.

  • refcursor or object?

    Working on a stored procedure that is called by the java application.

    I do not know which of the following option is better and in which case:

    1 stored procedure return/accepting a SYS_REFCURSOR parameter
    or
    2. at the level of schema:

    TYPE AS OBJECT emp_attrb_obj (attribute_type_id NUMBER (10),)
    attribute_val VARCHAR2 (50)
    );
    create or replace
    TYPE emp_attrb_type AS THE emp_attrb_obj TABLE;

    and then have a stored procedure accepts or returns a parameter of type emp_attrb_type

    Thank you
    RN

    RN says:
    Working on a stored procedure that is called by the java application.

    I do not know which of the following option is better and in which case:

    1 stored procedure return/accepting a SYS_REFCURSOR parameter
    or
    2. at the level of schema:

    TYPE AS OBJECT emp_attrb_obj (attribute_type_id NUMBER (10),)
    attribute_val VARCHAR2 (50)
    );
    create or replace
    TYPE emp_attrb_type AS THE emp_attrb_obj TABLE;

    and then have a stored procedure accepts or returns a parameter of type emp_attrb_type

    Thank you
    RN

    Well, a java application is unlikely to be able to pass a ref cursor, your procedure will therefore not need to accept a. Other than that, it really depends on how the data that you expect to get past back.

    I have a number of stored procs called by java applications that return a single row in a table. In these cases, I often return an object, since it saves a step for Java guys who can use it more or less directly. Is there is not a limit on the number of rows returned exlplicit, then I would always return a refcursor.

    If the java app must pass a set of values in the stored procedure (for example get this list of employees), then I would have java pass an array of objects (an array of records) to the stored procedure. It keeps me from having to parse a delimited string of values.

    John

  • Call a procedure only once for the last place of the trigger FOR EACH ROW

    Hello world

    I wonder if someone could help me in the execution of the trigger. My use case what follows:

    -a trigger after each INSERT or UPDATE operation;
    -use FOR EACH ROW algorithm for relaxation;
    -collect certain values inserted/updated fields as: new.uuid and store in a set defined on the layer of the package;
    -only for the last inserted/updated line call a procedure from the global collection with the values collected as a parameter;

    Is it possible to be implemented for the type of the LINE FOR EACH of the trigger? Fact one: new identifier or trigger itself have special attributes such as COUNTY, SIZE to set a size of data inserted or changed to conditional logic? Is there another solution to possible workaround for thoughtful use cases.

    Thank you

    Andrey

    Hi, Andrey,

    I suggest you use 2 triggers:
    (1) A FOR EACH ROW trigger, as you described, to collect relevant data and store it in a temporary table overall or variable poackage. Whenever the trigger is activated, it will overwrite all the data from the previous row.
    (2) AFTER ( NOT FOR EACH ROW) trigger that calls the procedure by using the saved data.

Maybe you are looking for

  • Invisible router 'behind' the time Capsule

    Hej there. technical question, I don't know why it works like this. our network configuration looks like: 1 - modem DSL (free WIFI), working as router and DHCP in the network (192.168.1.1) 2 Time Capsule is connected to the Modem DSL-(via the WAN Por

  • HP elite 8000 usdt: HP elite 8000 usdt audio good DP

    Hello strugglin for 2 days im getting my hp elite 8000 usdt pc for video and audio rendering on my Samsung smart TV. The problem is that I have no audio on my TV through displayport to hdmi adapter adapter. According to what ive read on the internet,

  • This video converter for macbook?

    I'm looking for a video converter that converts mainly .mov .avi or MP4 files, and also allow to edit the video. Not really as long as it is available in a single application or both applications. Have you tried several downloads, but they seem to be

  • OfficeJet 6830 E3E02A: problem with printhead

    It is said in the Panel problem with printhead... Help

  • Should I upgrade my macbook mid 2012 lion 10.7.5 pro to El capitan?

    Some things have worked odd how wifi does not immediately connect and safari in place, and El capitan appears to be sound got some interesting features and is relatively stable, so I think the upgrade. However, I wonder if my material from mid-2012 (