How to increment the value by using "FORALL" instead of loop for

declare

VAR_TYP TYPE IS VARRAY (32767) OF VARCHAR2 (32767).

V_DSH_CM_NUMBER VAR_TYP;
V_DSH_DATE VAR_TYP;
V_DSH_TIME VAR_TYP;

V_DSD_CM_NUMBER VAR_TYP;
V_PLU_CODE VAR_TYP;
V_DSD_DATE VAR_TYP;
V_str_id VAR_TYP;

LN_ITM NUMBER: = 0;
number of STR_ID: = 30001;

CURSOR CUR_DBMG_SAL_HEAD
IS
SELECT DSH. CM_NUMBER, D_DSH_CM_DATE, D_DSH_CM_TIME
OF DBMG_SAL_HEAD DSH
WHERE ROWNUM < 6;

BEGIN
CUR_DBMG_SAL_HEAD OPEN;
LOOP
COLLECT FETCH CUR_DBMG_SAL_HEAD IN BULK
BY V_DSH_CM_NUMBER,
V_DSH_DATE,
V_DSH_TIME;

FOR indx IN V_DSH_CM_NUMBER. FIRST... V_DSH_CM_NUMBER. LAST
LOOP
SELECT CM_NUMBER, V_DSH_DATE, PLU_CODE (indx)
TO COLLECT FEES IN BULK
IN V_DSD_CM_NUMBER, V_PLU_CODE, V_DSD_DATE
FROM DBMG_SAL_DETL DSD
WHERE DSD. CM_NUMBER = V_DSH_CM_NUMBER (indx);

-block1
FORALL ind IN 1.V_DSD_CM_NUMBER. COUNTY
INSERT INTO PC_ALL_TAB
VALUES (V_DSH_CM_NUMBER (indx),
V_DSD_DATE (IND),
V_DSD_CM_NUMBER (IND),
V_PLU_CODE (IND),
LN_ITM,
STR_ID
);

LN_ITM: = LN_ITM + 1;
-block2

END LOOP;

WHEN THE OUTPUT CUR_DBMG_SAL_HEAD % NOTFOUND;
END LOOP;

commit;

CLOSE CUR_DBMG_SAL_HEAD;
DBMS_OUTPUT. PUT_LINE('COMPLETE..!');
END;

o/p:-SELECT DSH_CM_NUMBER, LN_ITM FROM PC_ALL_TAB;

DSH_CM_NUMBER LN_ITM
4177424 0
4177422 1
4177426 2
4177426 2
4177426 2
4177425 3
4177427 4
4177427 4
4177427 4

I need result as below, for eachdsh_cm_number, I need incrementing value of ln_itm... but using 'FORALL '.

DSH_CM_NUMBER LN_ITM
4177424 0

4177422 0

4177426 0
4177426 1
4177426 2

4177425 0

4177427 0
4177427 1
4177427 2

Hello

Why not do it in single SQL?

As far as I can decode what you want (you seem to have too many variables), you try to do something like:

INSERT INTO pc_all_tab (dsh_cm_number,
                        dsd_date,
                        dsd_cm_number,
                        plu_code,
                        ln_itm,
                        str_id
                       )
  SELECT dsh.cm_number,
         dsh.d_dsh_cm_date,
         dsd.cm_number,
         dsd.plu_code,
         row_number () OVER (PARTITION BY dsh.cm_number ORDER BY NULL) - 1 AS ln_itm,
         '30001' str_id
  FROM   dbmg_sal_detl dsd, dbmg_sal_head dsh
  WHERE  dsd.cm_number(+) = dsh.cm_number
         AND ROWNUM < 6;

Concerning
Peter

Tags: Database

Similar Questions

  • How to find the value max and min of an attribute for a master VO

    Hello
    Is it possible to find maximum and minimum a master view object attribute values in groovy.
    I need to have the (START_DATE) min and max (end_date), values to pass to my Gantt chart to the table project start date and end date.
    For detail view objects, we can use < accessor > .max (start_date), but to see Master objects?

    I use jdeveloper 11.1.1.3.

    Thank you
    Guna.

    Published by: guna.b on December 13, 2010 11:01

    How about setting GOES to the same point of view and by using the groovy you mentioned in your message

  • How to read the value of list boxes by iteration in a loop For?

    I have a lot of list boxes on the front of my VI. I want to know how to read the value of this combo with a loop boxes For. The point is that I don't know how to get the reference of each combo box in a loop.

    Any information would be welcome. Thank you!

    su27 wrote:

    I have a lot of combo boxes on the front of my VI [...]

    Be sure to close the references that you have finished with them.

  • How to retrieve the values of character without using single quotes

    Hi all

    How to retrieve the values of character without the use of single quotes. Its Possible in Oracle SQL

    Please answer me...

    For example

    Is actual query-> Select * from employees where name like in("SCOTT", "JAMES", "ALBERT",...);

    I want to--> Select * from employees where name like(SCOTT, JAMES, ALBERT...); -without the use of single quotes.

    Why I need this application, I need to retrieve the records more than 200 employees in a select statement by using name in where clause.

    shagarmahabubjan wrote:

    Hi all

    How to retrieve the values of character without the use of single quotes. Its Possible in Oracle SQL

    Please answer me...

    For example

    Actual query is---> Select * from employees where name like in("SCOTT", "JAMES", "ALBERT",...);

    I want to---> Select * from employees where name like(SCOTT, JAMES, ALBERT...); -without the use of single quotes.

    Why I need this application, I need to retrieve the records more than 200 employees in a select statement by using name in where clause.

    In short... you can't.  The channels are channels, and SQL and PL languages dictate that the string literals are provided within single quotes.

    I don't see how trying to retrieve more than 200 records of employees in the select statement means that you must get rid of the quotes.

    Be clear in what you ask: Re: 2. How can I ask a question on the forums?

    and take note of the FAQ link davidp provided the solution "variable IN the list.

  • How to set the value of QUERY using PL/SQL process?

    Hello

    I use APEX 4.2...
    How to set the value of the REQUEST using process of PL/SQL which lies before the header - where the value of the REQUEST should appear on the URL?

    Kind regards
    Fateh

    You cannot set a value of demand in a PL/SQL block. You can run a PL/SQL block on a request which is the id of a button for example.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    http://Apex.Oracle.com/pls/Apex/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • How XPoweredByHeaderLevel the value None using wlst

    How XPoweredByHeaderLevel the value None using wlst (default value is SHORT).

    I mean, I created a domain using wlst.
    Now, I want to put some XPoweredByHeaderLevel of WebAppContainerMBean votes to ZERO using wlst.
    It will be useful if an example of python (Jython) script is provided.

    Help, please.

    Here is a small example of Jython how to do what you want:

    #assuming you already have correct imports for wlst module

    #connect to the AdminServer using the appropriate authorities and host information

    WLST. Connect (username, password, host_info)

    domain #extract
    domainName = wlst.domainName

    #start change a session and navigate to the WebAppContainerMBean

    WLST. Edit()
    WLST. CD ("/WebAppContainer/" + domain name)
    wlst.startEdit)

    #set attribute to the value of the XPoweredByHeaderLevel to 'NONE '.
    wlst.cmo.setXPoweredByHeaderLevel ("NONE")

    #activate change
    WLST. Activate()

  • How to save the value controls in labview

    Hello
    I want to know how to record the value of controls in the PC. means if I attribute 5 numeric value to a control, he has to stay there even I restart my PC.

    And here is a simple example of using - http://decibel.ni.com/content/docs/DOC-15349

  • How to connect the value of the input string to numeric values

    Hello

    I'm trying to figure out how to connect the value of unique user input string to numeric values. Basically I want the user to enter the name of a gas that I have a list for (I think I put the list of gases in a table >). Then I want to match numeric values 2 'a' and 'b', according to which gas, name of the user has set. These 'a' and 'b' values will be automatically matched with the name of the gas in a list that I put. For example, hydrogen gas has the value 3 for "a" and 4 for "b. when the user puts the ' hydrogen' name in a string constant, automatically 'a' and 'b' must be issued.» I have connect a and b to a formula

    Thanks for any help

    Hello

    It is perhaps not exactly what you are looking for, but perhaps you could use the enumerated data type and the array of clusters of points (a, b).

    Look at the VI I enclose.

  • How to get the value of the TextField on Buton FieldChangeListener

    friends I am new on the development of blackberry applications could you please help me how to get the value of text I typed in the textField when I click the button?

    constructor

    public Dialogs()
    {
      
    using design in the same screen
      
    Display display = new MainScreen();
      
    ButtonField btnPress = new ButtonField();
    btnPress.setLabel ("press me");
    btnPress.setChangeListener (ButtonPressListener);
      
    TxtValue TextField = new TextField();
    txtvalue.setLabel ("enter something :");
      
    HFM VerticalFieldManager = new VerticalFieldManager (VerticalFieldManager.FIELD_VCENTER);
    HFM. Add (txtValue);
    HFM. Add (btnPress);
      
    mainScreen.add (hfm);
    pushScreen (mainScreen);
      
      
    }

    FieldChangeListener ButtonPressListener = new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
        
           
    Dialog.Alert (t.GetText ());
         
         
         
    }
    };

    any help would be appreciated.

    You must ensure that your FieldChangeListener has access to the object of txtvalue, while it can make a

    String inputString = txtvalue.getText ();

  • How to reset the value of a list of entry of null values

    Hello

    Jdev 12.1.3.0

    How to reset the value of a list of entry of null values

    Thank you

    AR

    Place this code in your ViewRowImpl (base) class and use it when you need to reset _all attributes applied by LOV

    @Cvele: in fact, this will happen "by design" when you set the attribute which has attached lov to null, so there is no need of additional code.

    See also this blog: binary: prevent the execution of query unwanted in British Colombia ADF when used in Non - UI applications

    My previous answer is more related to this approach:

    DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding iterator = bindings.findIteratorBinding("IteratorName");
    Row r = iterator.getCurrentRow();
    r.setAttribute("SomeAttrib", null);
    

    Dario

  • How to read the values of the field of LOV disabled?

    Hi all

    I have a requirement, based on values that we entered one of the LOV fields, then we are arising from the new values based on the value that we entered this field of LOV. And then I must by default new LOV values derived in a two other fields of LOV and then disable them. Once the fields are disabled, then I'm not able to read the values using the pagecontext.getparameter... I get nothing when I tried to read using the pagecontext.getparameter.

    Pointers on how to read the values of disabled field/LOV?

    Thank you
    Clarriiza

    1. you already have values, and that's what you set in the LOV before turning off, right? So why do you need to recover again from the LOV.

    2. are you disabling or making it readonly? I think that if it is disabled, you might still be able to get the value using pageContext.getParameter.

    3 have you tried to get the handle to the LOV bean and get the value using lovBean.getValue (pageContext)?

    4. another Option is to combine the value of a FormValue Bean also (as well as the LOV bean) and retrieve it from FormValue.

    5 BTW, why are, why you're seen LOV if you disable it? Can't you just a TextBox?

    See you soon

    AJ

  • How to display the value of the variable for bottom of pl/sql

    How to display the value of the variable for bottom of pl/sql

    declare

    V_1 number: = 10;

    V_2 number: = 20;

    V_3 number: = 30;

    v_4 number: = 40;

    v_5 number: = 50;

    test varchar2 (100);

    Start

    I'm in 1.5

    loop

    test: = "v_" | I have;

    dbms_output.put_line(i||) e > ' | test);

    end loop;

    end;

    /

    How to get below output:

    1 > v_1

    2 > v_2

    3 > v_3

    4 > v_4

    5 > v_5

    But I want to output of

    1 > 10

    2 > 20

    3 > 30

    4 > 40

    5 > 50

    Hello

    You cannot reference variables as you did and get the value of the variable. Use pretty collection.

    set serveroutput on size 2000
    declare
      type      number_table is table of number;
      numbers   number_table := number_table(10, 20, 30, 40, 50);
    begin
      for i in numbers.first .. numbers.last
      loop
        dbms_output.put_line(i || '->' || numbers(i));
      end loop;
    end;
    /
    
    anonymous block completed
    1->10
    2->20
    3->30
    4->40
    5->50
    

    See the Collections of PL/SQL and Records http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005

  • How to choose the value of a string are numeric together and words of letters (for example, TEST)

    Hi all

    How to choose the value of a string are letters (for example, TEST) and all numeric...

    for example
    TEST 123456
    TEST 34567
    123456 ABCD
    1234 TEST
    TESTING 12345
    TEST 1@234$
    YOUR T 123456

    I want the results of the query as below.
    TEST 123456
    TEST 34567

    And I tried to use regexp_like in this case but without success. See the code below.
    SELECT * FROM TABLE WHERE regexp_like (Description, ' [TEST] % & [[: digit:]] + $');

    How can I do this, please answer.

    Thank you

    WF

    If you want to return only the rows that contain the string 'TEST', followed by zero or more space characters, followed by one or more digits?

    How about this:

    SELECT *.

    FROM my_table

    WHERE REGEXP_LIKE(description,'^TEST\s*\d+$')

  • How to find the value dated the same day in the last year

    I want to know how to find the value dated the same day in the last year.

    I use now, there is the function with the year and the result is

    Year Rev There are Rev
    20113000
    201240003000
    201320004000
    201450002000

    It works but it's not that I want. I'm trying to add the column date (Ex.20140101) in my report but it'snot work.

    I want to show:

    Date Rev There are Rev
    20110112200
    20120112100200
    20130112300100
    20140112500300

    If use (< degree >, < time_dim >. < date >, 365), it works but does not correct 100%

    Please help me...

    Thank you very much

    Check this link cool - bi.com

  • How to get the value on a model that is defined in the java code in email

    Hello

    I created a custom code and send email as well to custom component. I can send emails using the method:

    InternetFunctions.sendMailTo (EmailID, EmailTemplate, subject, cxt);

    But my problem is that I have to get a value in the model of "EmailTemplate" which are defined from java code. but I don't know how to get the value.

    I will highlight in the java code by using this code: binder.putLocal ("ErrorApproveRejectMsg", massegeBody);

    I'm trying to enhance the model using the code below, but not able to get.

    1 < $exec getValue ("#active", "ErrorApproveRejectMsg") $ >

    2 < $exec getValue ("#active", ErrorApproveRejectMsg) $ >

    3 < getValue ("ErrorApproveRejectMsg") $exec $ >

    4 < $exec getValue (ErrorApproveRejectMsg) $ >

    5 < getValue ("#local", ErrorApproveRejectMsg) $exec $ >

    6 < getValue ("#local", "ErrorApproveRejectMsg") $exec $ >

    7 < $ErrorApproveRejectMsg$ >

    8 < $exec ErrorApproveRejectMsg$ >

    Assuming that cxt will be your Service or execution context object

    You can do something like this

    DB. PutLocal ("ErrorApproveRejectMsg", "Error");

    cxt.setCachedObject ("DataBinder", db);

    PageMerger h = new PageMerger (db, cxt);

    cxt.setCachedObject ("PageMerger", h);

    InternetFunctions.sendMailTo (usersEmail, emailTemplate, emailSubject, cxt);

    where db is current databinder object, and you can put any variable custom in the workbook by using the putLocal method.

    Thank you

    Vikram

Maybe you are looking for

  • MAIL UPGRADE 10.11 fails

    After upgrade to El Capitan in Yosemite, a popup labelled 'Mail Upgrade' kept appearing, disappearing and reappearing.  A text read, by turns "redevelopment of library" and "data migration" accompanied by a warning tone whenever he disappeared and re

  • Save the changes without confirmation of Excel

    I finished my program with Excel communications.  It works fine but when the program close XL, it sends a confirmation of savings, I would save all changes automatically, without confirmation I tried with a node to invoke with the SaveAs method but h

  • 'Touch bar' malfunction-/ enable internet connectivity

    I have a HP Pavilion dv8t.  Is there a way to disable the contact bar along the top of the keyboard?  My internet connection goes periodically on and outside, and the bar of volume and/or bass/treble will be displayed on the screen, don't not allowin

  • How to find the homegroup password

    Why my laptop used which has enabled homegroup don't watch not the password for other PCs connect so that the will has not left me disconect homegroup it has implemented.  My another laptop detects but I can't join because cannot change or find passw

  • I need help to fill out a spread on my tablet. It will not come as long as and are always asking me to save it.  Not even save as

    I'm filling out fillable forms using my tablet that I created on my laptop that it does not come in as a savable form save not save that I need to be able to get this working so I can send it to my employees