How to pass record set as procedure parameter.

Hi All,
I have a requirement, I want to pass the records that are fetched from a cursor to a procedure as a parameter.
I dont want to use it inside the loop as we do it normally, as i might get huge volume of records using cursor, as a result the procedure also will be called number of times inside the loop.
Can you suggest me the logic along with sample code?
Thanks
Suresh

GSKumar wrote:
I have a requirement, I want to pass the records that are fetched from a cursor to a procedure as a parameter.A cursor outputs rows - not "records".
I dont want to use it inside the loop as we do it normally, as i might get huge volume of records using cursor, as a result the procedure also will be called number of times inside the loop.
Can you suggest me the logic along with sample code?How else do you want to do it? If there are a million rows returned by the cursor, it means a million executions of that procedure - once for every row.
This will be slow. And the primary reason is that executing a PL/SQL procedure (or any other code unit) for a million times, will be slow. Changing the cursor interface (from an implicit cursor to a ref cursor for example) does not change the fact there needs to be a million PL/SQL procedure executions - and does not make anything faster. To fetch rows from a cursor needs to a loop. Period.
There are two basic ways to address this issue at hand.
Use SQL and not PL/SQL. Instead of using PL/SQL code and logic, use SQL code and logic. This will be faster as the PL/SQL engine no longer plays a role and a million rows do not have to be send from the SQL engine to the PL/SQL engine. Instead that million rows are processed internally in the SQL engine - which will be faster. And which will provide scalable options such as using parallel query.
Use "multi-threaded" PL/SQL. Assuming the PL/SQL code and logic are too complex to be done in SQL, the next best choice is PL/SQL. However, a single serialised PL/SQL process going through a million rows will be slow and will not scale. If parallel PL/SQL can be used, then 20 PL/SQL processes can each do 50,000 rows - as oppose to having to do a million rows.
There are two options to "multi-thread" PL/SQL code. You can use DBMS_PARALLEL_EXECUTE (11g). You can use a parallel pipelined table function (10g and higher).

Similar Messages

  • How to pass record Group from Forms with DATA_PARAMETER to Reports Server

    How to pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    When we use products on run time we are using data_parameter for passing record Groups to reports via run_product but now we have to use application server and reports server for same reports.
    We met with <FRM-41214 Unable to run reports> for passing DATA_PARAMETER to reports server when used RUN_REPORTS_OBJECT.
    How can we pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    Thanks,
    Arif

    Hi Mandeep,
    Could you please tell me how can i pass data parameter from forms to report through run_product.

  • How to Pass Record Group to Reports Server ?

    How to pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    When we use products on run time we are using data_parameter for passing record Groups to reports via run_product but now we have to use application server and reports server for same reports.
    We met with <FRM-41214 Unable to run reports> for passing DATA_PARAMETER to reports server when used RUN_REPORTS_OBJECT.
    How can we pass record Group from Forms with DATA_PARAMETER to Reports Server using RUN_REPORT_OBJECT?
    Thanks,

    how come the online help in forms 10g says you can?
    or am I missing something.
    there is a section on it.
    >
    Passing Record Groups to Reports or Graphics
    You can pass a record group to Reports or Graphics as a DATA parameter. This DATA parameter is a special type of parameter that gives a signal to the integration code to substitute the contents of the record group whose name you give for the results of the query named by the query name you indicate.

  • How to pass  internal table values to parameter

    hi,
             how to pass  internal table values to parameter in selection screen.if is it possible means please sent codeings.
    thanks.
      stalin.

    hi,
    tables : mara.
    data :  begin of itab_mara occurs 0,
              matnr like mara-matnr,
              ernam like mara-ernam,
              end of itab_mara.
    selection-screen : begin of block blk1 with frame title text-001.
    parameters : p_matnr like mara-matnr.
    selection-screen : end of block blk1.
    select matnr ernam from mara into corresponding fields of itab_mara
                                                                    where matnr = p_matnr.
    loop at itab_mara.
    write :/ itab_mara-matnr,
               itab_mara-ernam.
    endloop.
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • How to pass class object  as in parameter in call to pl/sql procedure ?

    hi,
    i have to call pl/sql proecedure through java. In pl/sql procedure as "In" parameter i have created "user defined record type" and i am passing class object as "In" parameter in call to pl/sql procedure. but it is giving error.
    so, anyone can please tell me how i can pass class object as "In" parameter in call to pl/sql procedure ?
    its urgent ...
    pls help me...

    793059 wrote:
    I want to pass a cursor to a procedure as IN parameter.You can use the PL/SQL type called sys_refcursor - and open a ref cursor and pass that to the procedure as input parameter.
    Note that the SQL projection of the cursor is unknown at compilation time - and thus cannot be checked. As this checking only happens at run-time, you may get errors attempting to fetch columns from the ref cursor that does not exist in its projection.
    You also need to ask yourself whether this approach is a logical and robust one - it usually is not. The typical cursor processing template in PL/SQL looks as follows:
    begin
      open cursorVariable;
      loop
        fetch cursorVariable bulk collect into bufferVariable limit MAX_ROWS_FETCH;
        for i in 1..bufferVariable.Count
        loop
          MyProcedure( buffer(i) );   --// <-- Pass a row structure to your procedure and not a cursor
        end loop;
        ..etc..
        exit when cursorVariable%not_found;
      end loop;
      close cursorVariable;
    end;

  • How to pass a cursor as IN parameter to a procedure

    Hello
    I want to pass a cursor to a procedure as IN parameter.
    See the below piece of code:
    Cursor mycur is select * from table_name;
    Procedure myproc(mycur IN ...)
    begin
    fetch mycur into v_rec;
    {want to do some updates here}
    end;
    Please suggest how can I pass the cursor?
    Thanks in advance !!!!

    793059 wrote:
    I want to pass a cursor to a procedure as IN parameter.You can use the PL/SQL type called sys_refcursor - and open a ref cursor and pass that to the procedure as input parameter.
    Note that the SQL projection of the cursor is unknown at compilation time - and thus cannot be checked. As this checking only happens at run-time, you may get errors attempting to fetch columns from the ref cursor that does not exist in its projection.
    You also need to ask yourself whether this approach is a logical and robust one - it usually is not. The typical cursor processing template in PL/SQL looks as follows:
    begin
      open cursorVariable;
      loop
        fetch cursorVariable bulk collect into bufferVariable limit MAX_ROWS_FETCH;
        for i in 1..bufferVariable.Count
        loop
          MyProcedure( buffer(i) );   --// <-- Pass a row structure to your procedure and not a cursor
        end loop;
        ..etc..
        exit when cursorVariable%not_found;
      end loop;
      close cursorVariable;
    end;

  • How to pass value to select-option parameter using SET PARAMETER Command

    Hi,
        Am passing values to selection-screen fields in report RV13A004 ( used in VK11, VK12 and VK13). using below statement but material number is select-option in this report. am able to pass  MATERIAL FROM using SET PARAMETER ID, can i know how to pass values MATERIAL TO range in select-options fields using SET PARAMETER Command ??
    Passing values to parameter id
    set parameter id 'VKS' field kschl.
    set parameter id 'VKO' field vkorg.
    set parameter id 'VTW' field vtweg.
    set parameter id 'KDA' field erdat.
    set parameter id 'MAT' field matnr_from.
    Change condition price.
    call transaction 'VK12' and skip first screen.
    Thanks in advance.
    Regards,
    Balamurugan.

    Hi,
    instead of using set parameters and dden call transaction use this..........
    submit RV13A004  WITH SELECTION-TABLE rspar
    Effect
    If you specify this addition, parameters and selection criteria on the selection screen are supplied from an internal table rspar. You must specify an internal table with the row type RSPARAMS for rspar. The structured data type RSPARAMS is defined in the ABAP Dictionary and has the following components, all of which are data type CHAR:
    SELNAME (length 8),
    KIND (length 1),
    SIGN (length 1),
    OPTION (length 2),
    LOW (length 45),
    HIGH (length 45).
    To supply parameters and selection criteria for the selection screen with specific values, the lines in the internal table rspar must contain the following values:
    SELNAME must contain the name of a parameter or selection criterion for the selection screen in block capitals
    KIND must contain the type of selection screen component (P for parameters, S for selection criteria)
    SIGN, OPTION, LOW, and HIGH must contain the values specified for the selection table columns that have the same names as the selection criteria; in the case of parameters, the value must be specified in LOW and all other components are ignored.
    If the name of a selection criterion is repeated in rspar, this defines a selection table containing several lines and passes it on to the selection criterion. If parameter names occur several times, the last value is passed on to the parameter.
    The contents of the parameters or selection tables for the current program can be entered in the table by the function module RS_REFRESH_FROM_SELECTOPTIONS.
    Notes
    In contrast to selection tables, the data types of the components LOW and HIGH in table rspar are always of type CHAR and are converted to the type of the parameter or selection criterion during transfer, if necessary.
    When entering values, you must ensure that these are entered in the internal format of the ABAP values, and not in the output format of the screen display.
    Cheers
    Will.

  • Pass records from one procedure to another

    hi,
    I have created following procedure. It takes input parameter and selects some records in EMP table based on condition.
    How to pass the output from this procedure to another procedure to manipulate the selected records further.
    Do I need to pass REF CURSOR or RECORD ?
    Thanks
    ===================================================
    create or replace procedure empdetails(pid IN number)
    is
    type ref_cur is REF CURSOR;
    rc ref_cur;
    type myrec is RECORD(id number, name varchar2(15), sal number);
    rec myrec;
    begin
    open rc for select id, name, sal from emp where deptid=pid;
    loop
    fetch rc into rec;
    exit when rc%notfound;
    dbms_output.put_line(rec.id||'--'||rec.name||'--'||rec.sal);
    end loop;
    close rc;
    end empdetails;

    don123 wrote:
    I have created following procedure. It takes input parameter and selects some records in EMP table based on condition.
    How to pass the output from this procedure to another procedure to manipulate the selected records further.
    Do I need to pass REF CURSOR or RECORD ?Record. The bulk collection approach is useful if you want to use the collection subsequently as a bind variable for bulk binding. But assuming you simply want to crunch data, the minimalistic approach would be:
    SQL> declare
      2          procedure ProcessEmp( e emp%RowType ) is
      3          begin
      4                  dbms_output.put_line( 'processing employee..'||e.ename );
      5          end;
      6  begin
      7          for e in(select * from emp order by 1) loop
      8                  ProcessEmp(e);
      9          end loop;
    10  end;
    11  /
    processing employee..SMITH
    processing employee..ALLEN
    processing employee..WARD
    processing employee..JONES
    processing employee..MARTIN
    processing employee..BLAKE
    processing employee..CLARK
    processing employee..SCOTT
    processing employee..KING
    processing employee..TURNER
    processing employee..ADAMS
    processing employee..JAMES
    processing employee..FORD
    processing employee..MILLER
    PL/SQL procedure successfully completed.
    SQL> An implicit bulk collect is done by the FOR loop, courtesy of the PL/SQL optimiser. As the procedure ProcessEmp() does not perform SQL processing itself (e.g. using employee data to fire off UPDATE, DELETE or INSERT SQL statements), a collection is not really needed as it would not contribute to the procedure's performance.
    If however nested SQL statements are fired from inside that cursor fetch loop, using a collection would enable these SQLs to make use of bulk binding.
    However, this approach ALWAYS need to be question, examined and validated - as a single SQL can often be used, combining the outer read/fetch loop (SELECT), with the nested SQLs (UPDATE/INSERT) done - using the MERGE or INSERT..SELECT statements for example.
    Explicit bulk processing should be an exception - as pushing data from the SQL engine to the PL/SQL engine, only to push that PL/SQL engine's data back to the SQL engine, is invariable a flawed, non performant, and non scalable approach.

  • How to put record set in loop

    Using the follwing query
    select distinct code from oalr where code > '" & AlertCode & "' and  code<=('" & code & "') "
    i got 5 records eg :5603,5604,5605,5606,5607
    record set fetching
    Ocode = CStr(rs4.Fields.Item(0).Value)
    Here  Ocode get only last record eg :5607, i want to take this 5 records in the loop how can i write the coding

    Thank for ur reply,
    But i not passing this in to matrix , i m going to pass the value in to anothe record set
    eg
    Ocode = CStr(rs4.Fields.Item(0).Value)
    select A.code,A.MsgData,B.UserSign,C.Portnum as MobileNum from OALR A inner join ALT1 B on A.Tcode=B.code inner join OUSR  c on C.UserID=B.UserSign where  A.code='" & Trim(Ocode) & "' ")
    I want to pass the Ocode value in to the loop.becoz only one value pass this query next time pass means duplicate value prob occure so i want to pass the Ocode value up to EOF. Give some solution

  • How to passing multiple values for a parameter of discoverer(url parameters

    Hi All,
    I am trying to pass multiple values for a parameter of disco report. I am trying to include my url for discoverer viewer report. the values has the following
    'jeff,mark'
    'sfophiee,angela'
    Thanks and Regards
    Venkat

    Hello Venkat,
    I know there are some problems with 10.1.2.0.2, maybe if you haven't done yet you can try with 10.1.2.2, assuming this version should be working for multiple parameter values :
    OracleAS Discoverer 10.1.2.2 is installed with the following patch :
    Patch 4960210 PLACEHOLDER BUG FOR AS/DS 10G R2 PATCH SET 2 10.1.2.2
    So, once installed you can try adding your parameter as param_<parameter_name>='sfophiee,angela'
    Hope this helps, otherwise feel free to log a Service Request to Support.
    Best Regards,
    Gianluca

  • How to pass value in Table import parameter of an RFC

    Hi all,
    I have an RFC in which import parameters are in the form of a table
    so now when i imported that RFC in my webdynpro application and Apply Service Template to it, it created the structure but when i applied form template to it all the inputfields were readonly
    and also when i tried to set the input parameter of that table like:
    wdContext.currentBAPI_CREATEElement.set<field>("value");
    it shows null pointer exception
    MY Context structure created after service template is as follows:
    Model Node Zcreate_rfc, it icludes another model node
    BAPI_CREATE, and it then includes the input parameters
    Please tell me how to solve the problem

    Suppose the RFC is called ZRFC, and the table structure is called TableStruct, then this works for me (in execute method before calling execute):
    ZRFCInput input = wdContext.currentZRFCElement().modelObject();
    // these are regular import parameters
    input.setAaa(aaa);
    input.setBbb(bbb);
    if (input.getTableStruct()!=null) {
          input.getTableStruct().clear();
    // In this loop table rows are added
    for (int i=0; i<sourcList.size(); i++) {
         ZTableStruct table = new ZTableStruct();
         table.setDdd(((SomeBean) sourcList.get(i)).getDdd()); // for property ddd
         input.addTableStruct(table);
    Good luck, Roelof
    Edited by: R. Knibbe on Jan 23, 2008 3:25 PM

  • SSRS How to pass a value for Hidden parameter ?

    Hello,
    I have a SSRS report deployed on the Report server. This report is having an "Hidden" parameter.
    Could someone please guide me, how to pass the value to this internal parameter in each of the following case - 
    1. Report is accessed through a Desktop application/Web application in Report Viewer.
    2. Report is accessed through the Url.
    3. Report is accessed through the Report Manager.
    Any quick help on this is highly appreciated.
    Thanks!
    -Vinay Pugalia
    If a post answers your question, please click "Mark As Answer" on that post or
    "Vote as Helpful".
    Web : Inkey Solutions
    Blog : My Blog
    Email : Vinay Pugalia

    Hi Vinay Pugalia,
    Internal Parameters in SSRS are parameters that are not configurable by the end-user at run-time and values cannot be passed to this type of parameter (when present in the child report) in case of a drill-through report implementation. This
    type of parameter is read-only and not accessible in parent report.
    This varies from a Hidden Parameter, which the user is not prompted to provide, but can still be configured through the URL to the report server.
    So no matter you access the report through report manager, URL or Report Viewer. The passing value to the internal parameter will not work.
    As you have mentioned that I will also suggest you use the hidden parameter instead.
    More details information in this blog for your reference:
    SSRS – Understanding Report Parameter Visibility
    How to pass value to  hide parameter is the same as that of the visible parameter, similar thread for your reference:
    Passing the value in action property of a text box
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • How to pass an object as a parameter

    how do you pass an object as a parameter? (what type should it be ?)

    Well you can use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html]String
    Or you can take a [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html]Double
    And you can pass [url http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Event.html]Events
    and get yourself in trouble
    and you can use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Frame.html]Frame
    or maybe take a [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html]List
    but some will use [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html]Collection
    depends you your direction
    so if you need to know
    if you should use a [url http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html]Map
    then this is what to do
    just browse the [url http://java.sun.com/j2se/1.4.2/docs/api/]API

  • HOW TO PASS SELECT-OPTIONS AS IMPORT PARAMETER TO A CLASS

    Hi experts,how to pass select options value as a export parameters to a zclass.
    can  give me some idea.
    Thanks
    sai

    As Sachin already said, selection options are stored in an internal table. You can reconstruct the table type without the corresponding input fields using the type addition RANGE OF.
    So - assuming you have the following in your program:
    DATA: wa TYPE sflight.
            SELECT-OPTIONS so_car FOR sflight-carrid.
    you can create a publically-visible type in your class using direct type entry and the code
    TYPES: my_selectoption TYPE RANGE OF sflight-carrid.
    and use this to define the importing parameter of the method.
    The only other thing you have to remember is that select-options generates an internal table with header line. Thereore, to pass the table to the method, you would use (in the above example) so_car[], and not just the name of the select-option.
    Hope this helps.
    Regards
    Jon.

  • How to pass a Class as a parameter of a method?

    I have a method like below. Inside this method I need to create a variable that his type is the type of the class I have passed as a method's parameter.
    For example, if I call the method like this "Meth1(ClassPerson);" insed the method I need to declare a  variable of class "ClassPerson", but if I call like "Meth1(ClassCity);" I need the same variable to be declared as a ClassCity.
    public function Meth1( /*I dont know what to put here*/   ):void{
         /*I dont know what to put here to declare my variable*/
         /*here
         comes
         more
         code
         using
         the
         variable*/
    I tried as below but dont worked:
    public function Meth1( classtype:Class):void{
         var var1:classtype = new classtype();
    Can someone help me?

    evyatarBH, after declare the variable like you said an error occurs when I try to access some property of the variable. I receive a mesage telling that this property dont exists.
    public function Meth1( classtype:Class ):void{
         var var1:* = new ClassFactory(classe);
         //when I try to do something like the line below the error appear
         inputtext1.text = var1.fieldname;
    rashare, I can't do this because I can't declare the object before the method is called. I must inform to the method only which class I will use, but the object must be created only inside the method.

Maybe you are looking for

  • How to create Auto weakly backup in Windows Server 2012

    Hello        1. I want to set auto backup in windows server 2012 Weakly. 2. can i Set auto backup like a normal data copy.

  • Can't access files though time machine

    In Time Machine I can see that folders are there but when I try to restore them I get nothing. I might get an empty folder that says "xxx(original)" but nothing's in it. Or I get a message about lacking permission. Is there a practical way to get at

  • Air 2.6 Screen orientation

    I'm trying to get this Air 2.6 feature to work again. http://kb2.adobe.com/cps/891/cpsid_89107.html Changes in AIR 2.6 Screen orientation changes in 2.6 namespace Based on the release doc, it says "The swf is required to be compiled with the flag "-t

  • Appletviewer Please Help

    I feel bad about asking help. But I don't know where else to turn to. I searched the archives to no avail. I'm not sure this is a CLASSPATH problem or what but every time I run appletviewer I get "I/O exception while reading: E:\j2sdk1.4.0\bin\e:\jav

  • After Backup In iTunes - All Media Content Is Deleted - iPhone 3G 16GB/8GB

    I have the latest iPhone Update 3.1 on my wife's 8GB 3G & my iPhone 16GB 3G - We are running the latest iTunes on a 2008 intel iMac. Using separate Logins on iMac. Strange things have happened since backing iPhone up in iTunes 9 today. (Previous Back