Previous value of same variable

How can I compare previous value of same variable(result) with current value.
Example, result 1 > result 2 or not, result 2 > result 3 or not, result 3 > result 4 or not, result 4 > result 5 or not.
import java.util.Random;
public class Test {
public static void main(String args[]){
double A = 5;
Test Cal = new Test();
Cal.run(A);
void run(double A){
Random random = new Random();
double result;
int i = 0;
do{
i++;
result = A + random.nextGaussian() / 2;
System.out.println(result);
}while(i<5);
}

Welcome to the forum.
960130 wrote:
How can I compare previous value of same variable(result) with current value.introduce a temporarry (local) variable that gets the previous value of <tt>result</tt> before the latter is overwritten.
BTW: plese read
https://wikis.oracle.com/display/Forums/Forums+FAQ
Especially section Are there any useful formatting options not shown on the sidebar?
bye
TPD

Similar Messages

  • Values of same Variable(used in diff reports) shud be retained in a session

    Hello,
    We have an application cockpit. There are 12 to 13 different reports being used in that cockpit. Most of the reports use the same characteristic variables in the report.
    When we used to execute these reports in Ver 3.x, the variables used to retain their values in the same session. i.e. if for 0Material, user gave : 'TIP120' as a value in selection criteria in one report, then, if he executed another report after that, which uses the same variable on 0Material, then it retained its previous value: 'TIP120'. 
    Recently we have migrated to BW 7.0. Now, the variables no longer retain their values in the same session and the user has to type the value again. (personalization is an option but we want the variable should retain the values in same session).
    Any help/advise on this will be of great importance as the user is not very comfortable putting values again, each time he runs the report.
    Warm Regards,
    Sumita

    Hi,
    Although this may not be the ideal answer for your question. This is another solution for your Question.(Personalizing Variables)
    Go through this link... This will help you for sure
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/30ae3d47afd652e10000000a114084/frameset.htm
    Hope This Helps,
    Regards,
    rik

  • How to check empty string and null? Assign same value to multiple variables

    Hi,
    1.
    How do I check for empty string and null?
    in_value IN VARCHAR2
    2. Also how do I assign same value to multiple variables?
    var_one NUMBER := 0;
    var_two NUMBER := 0;
    var_one := var_two := 0; --- Gives an error
    Thanks

    MichaelS wrote:
    Not always: Beware of CHAR's:
    Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL:
    SQL> declare
      2    l_str1   char (10) := '';
      3    l_str2   char (10) := null;
      4  begin
      5  
      6    if l_str1 is null
      7    then
      8      dbms_output.put_line ('oh STR1 is null');
      9    elsif l_str1 is not null
    10    then
    11      dbms_output.put_line ('oh STR1 is NOT null');
    12    end if;
    13  
    14    if l_str2 is null
    15    then
    16      dbms_output.put_line ('oh STR2 is null');
    17    elsif l_str2 is not null
    18    then
    19      dbms_output.put_line ('oh STR2 is NOT null');
    20    end if;
    21  end;
    22  /
    oh STR1 is NOT null
    oh STR2 is null
    PL/SQL procedure successfully completed.
    SQL> alter session set events '10932 trace name context forever, level 16384';
    Session altered.
    SQL> declare
      2    l_str1   char (10) := '';
      3    l_str2   char (10) := null;
      4  begin
      5  
      6    if l_str1 is null
      7    then
      8      dbms_output.put_line ('oh STR1 is null');
      9    elsif l_str1 is not null
    10    then
    11      dbms_output.put_line ('oh STR1 is NOT null');
    12    end if;
    13  
    14    if l_str2 is null
    15    then
    16      dbms_output.put_line ('oh STR2 is null');
    17    elsif l_str2 is not null
    18    then
    19      dbms_output.put_line ('oh STR2 is NOT null');
    20    end if;
    21  end;
    22  /
    oh STR1 is null
    oh STR2 is null
    PL/SQL procedure successfully completed.
    SQL> SY.

  • How to use the same variable value for data entry and the planning sequence

    Hi,
    the scenario is the following:
    Using the WAD template a user enters cost center plan data. The cost center is selected by the chosen value for the variable "V1".
    Afterwards he shall push a button which starts a planning sequence (including saving the data and further functions). This planning sequence uses a filter that also contains the variable "V1".
    What or where has it to be defined that the planning sequence uses automatically the same value for the variable "V1" as selected for the data entry?

    You have to define in the planning function. The planning sequence is only a sequence and it read the planning functions underneath it.
    Ravi Thothadri

  • Compare the current value with the previous value in the same column

    Hi all,
    I have to include a statement in a query which allows to compare the current value of column A with the previous value of column A (same column). from there, I need to add a condition in order to have the expected result.
    Let's take an example to illustrate what I want to achieve:
    I have the following columns in table called 'Charges':
    Ship_id batch_nr Order_nr Price
    SID1111 9997 MD5551 50
    SID1111 9998 MD5552 50
    SID1111 9999 MD5553 50
    SID2222 8887 MD6661 80
    SID2222 8887 MD6662 80
    SID2222 8887 MD6662 80
    SID3333 6666 MD7771 90
    I want to check if the ship_id of row 2,3 (and more if available) is equal to the ship_id of row 1.
    If it is the case, then value 'together with the first batch_nr' in row 2 and 3 under Price column. If not, then keep the original value of Price column
    PLease see below the expected result:
    Ship_id batch_nr Order_nr Price
    SID1111 9997 MD5551 50
    SID1111 9998 MD5552 together with 9997
    SID1111 9999 MD5553 together with 9997
    SID2222 8887 MD6661 80
    SID2222 8887 MD6662 together with 8887
    SID2222 8887 MD6663 together with 8887
    SID3333 6666 MD7771 90
    Thanks in advance for your help, it is really urgent.
    Imco20030

    Hi,
    user11961002 wrote:
    Hi,
    Here is the query that I use:
    [ select
    sl.ship_id,
    o.ordnum,
    o.reffld_5 "BatchNR",
    sum(tc1.chrg_amt) "FreightPRC",
    sum(tc2.chrg_amt) "FuelPRC",
    sum (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt) "Total Price"
    from ord_line ol
    join ord o on (ol.ordnum = o.ordnum and ol.client_id = o.client_id)
    join shipment_line sl on (ol.ordnum = sl.ordnum and ol.client_id = sl.client_id and ol.ordlin = sl.ordlin)
    join adrmst a2 on (o.rt_adr_id = a2.adr_id)
    left join tm_chrg tc1 on (tc1.chargetype = 'FREIGHT' and tc1.chrg_role = 'PRICE' and tc1.ship_id = sl.ship_id)
    left join tm_chrg tc2 on (tc2.chargetype = 'FUELSURCHARGE'and tc2.chrg_role = 'PRICE' and tc2.ship_id = sl.ship_id)
    where sl.ship_id = 'SID0132408'
    group by o.client_id, o.ordnum, o.reffld_2, sl.ship_id, a2.adrnam, a2.adrln1, a2.adrpsz, a2.adrcty, a2.ctry_name,
    o.reffld_5, ol.early_shpdte
    order by ship_id
    ]That looks like the query you were using before you started this thread.
    Modify it, using the analytic fucntions FIRST_VALUE and LAG, like I showed you.
    I see that you did simplify the problem quite a bit, and it's good that you did that.
    It doesn't matter that your real problem involves joins or GROUP BY. Analytic functions are calculated on the results after all joins and GROUPS BYs are done. Just substitute your real expressions for the simplified ones.
    For example, in your simplified problem, there was a column called order_nr, but I see now that's it's really called o.ordnum. Where the solution I posted earlier says "ORDER BY order_nr", you should say "ORDER BY o.ordnum".
    Here's a less obvious example: in your simplifed problem, there was a column called price, but I see now that it's really SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt). Where the solution I posted earlier says "TO_CHAR (price)", you should say "TO_CHAR (SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt))". (You can't use an alias, like "Total Price", in the same SELECT clasue where it is defined.)
    I removed some columns from the select as they are not relevant for the wanted action like 'adress details or other references'.
    Now here is the result:
    Shipment ID     Order Number     WMS Batch     Freight      Fuel Price Order Total Price
    SID0132408     MDK-000014-05602649     04641401     110     10 120
    SID0132408     MDK-000014-05602651     04641402     110     10 120
    SID0132408     MDK-000014-05602652     04641363     110     10 120
    as you can see, the 3 orders have the same shipment ID.
    The expected result should be shown under column 'Total Price' as follows:
    Shipment ID     Order Number     WMS Batch     Freight      Fuel Price Order Total Price
    SID0132408     MDK-000014-05602649     04641401     110     10 120
    SID0132408     MDK-000014-05602651     04641402     110     10 tog with 04641401
    SID0132408     MDK-000014-05602652     04641363     110     10 tog with 04641401Okay, so those are the correct results that I asked for, plus the incorrect results you're getting now. Thanks; extra information doesn't hurt.
    But where is the raw data that you're starting with?
    It looks like you tried to format the code (but not the results) by typing this 1 character:
    before the formatted section and this different character
    after the formatted section. To post formatted text on this site, type these 6 characters
    before the formatted section, and the exact same 6 characters again after the formatted section.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • About give from one query to other the same value of a variable

    Hi Gurus,
    my problem is About give from one query to other the same value of a variable, i have a wad with a view, and this wad has some bottoms in javascript to go to anothers wad with charts, the problem is when i ran the query one, i put a value = calyear:2008 (Obligatory Variable), but when i click the bottom to go to the other query with the same variable, he ask me again a value,
    i want write a value just one time, and the others wad can recieve the first value that i put when the wad opened.
    i really need it , thanks !

    Hello Jorge,
    What you need here is Replacement path variable. Check out this link for more details:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/bd/589b3c494d8e15e10000000a114084/content.htm
    In the second query where you need the value (calyear:2008 from first query) create a Variable for calyear of type Replacement path, in Replacement tab you can select either query or variable by which it has to replaced. In your case, it has to be variable from the first query.
    Do let me know if this works. If this does not work I suggest you to use Web APIs to replace the variable values using Web APIs. Check out the details:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/29/4d15422ecce02ce10000000a1550b0/frameset.htm
    Hope this helps.
    Regards,
    Srini

  • Use two indicators for the same variable in two different VIs

    hello, I want to use two indicators for the same variable in two different VIs running at the same time
    should I use global variables?? I want to avoid because I have lot of variables and it would takes too much memory,I tried with this code but the value of the second indicator is not updated 
    I tried to use the queue and it works but the problem is as i said previously that i have many variables shoud I use a queue for each one??
    what should I do?
    thank you in advance
    cordialy
    Attachments:
    projet.zip ‏13 KB

    CrisSTine01 wrote:
    hello, I want to use two indicators for the same variable in two different VIs running at the same time
    I'm a huge fan of User Events to send updates to GUIs from who knows where.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How do I see values of global variables in a SAP system

    Hi Guys
    How do I get to see the values of global variables DIR_GLOBAL etc.
    Actually I wanted to run an archive for some IDOCs, and I configured a filepath for the same and gave it an address to my local system, now when I use SARA and after customising the logical path it gives me an error stating that "Logical file path is not completely maintained".
    So I resorted to one of the predefined paths ARCHIVE_DATA_FILE and it archived successfully but I am not able to figure out the exact path of the archived file can you please help??
    Best regards
    Sujoy

    Hello Sujoy,
    Execute transaction FILE, double click on Logical File Name Definition, then, scroll down to find ARCHIVE_DATA_FILE - double click on ARCHIVE_DATA_FILE.  Note what is entered in the Logical path field and then, go to Logical File Path Definition.  Look for the path name from previous step and highlight/select it and click on Assignment of Physical Paths to Logical Path.  From there, you can double click on the relevant Syntax group.  This will give you the path for where the archive file has been written to.
    I hope this explanation is not too confusing :-).
    Best Regards,
    Karin Tillotson

  • Calculating based on a previous value when initial column values differ from the rest

    Let me preface this by saying I am new to the BO world. I'm trying to build a report/chart that tracks incoming loads. The first supply on hand value is pulled from the database and each successive supply on hand is based on the previous row's values.
    In the supply arriving column below, the iniital value differs from the rest using the formula:
         =If [Row Number]=1 Then [First Supply Arriving] Else [Supply Arriving]
    The supply on hand uses the same idea, but is where I'm running into problems. The first column value should be [Supply On Hand], easy enough. Each successive column value needs to follow this equation:
         Previous([Supply On Hand] (this won't always be [Supply On Hand] though, only for the second row essentially - problem 1) + Previous([Supply Arriving] (same as problem 1, where this is first supple arriving for the second row and then supply arriving moving forward) - [Usage Rate]
    If someone could help me in getting the calculation to pull the previous values correctly without making a ton of variables, I'd greatly appreciate it. We just upgraded to 4.1

    Yes, the supply on hand and the supply arriving from the previous row need added together. The usage rate, which is a constant is then subtracted from that. The result is the on hand total for the next day.
    For example:
    Date
    On Hand
    Arriving
    Usage Rate
    9/9/2014
    100,000
    250,000
    100,000
    9/10/2014
    250,000
    1,000,000
    100,000
    9/11/2014
    1,150,000
    0
    100,000

  • Totalling values in a variable??

    Hi Swingers,
    I am able to multiply two values together and print the result to the screen, within a loop however i need to take this multiplied value and put it into a variable and everytime in the loop a value is worked out i then wanna add the previous value with the new value , the code below may make my problem a little more clear:
    public void getOrderTotal() {          
           int count = table.getRowCount();          
           for (int i = 0; i < count; i++) {               
                    if (table.getValueAt(i,4)== "") {               
                   else {                    
                           BigDecimal price =(BigDecimal)(table.getValueAt(i,3));               
                           String qty = (String)(table.getValueAt(i,4));                    
                           BigDecimal totalled = price.multiply(new BigDecimal(qty));                    table.setValueAt(totalled,i,5);                    
                         System.out.println(price+"\t"+qty+"\t"+totalled);                    
                          totalTotal = totalTotal.add(totalled);//TRYING HERE TO PUT VALUES IN VARIABLE totalTotal AND NULL POINTER EXCEPTION OCCURRING     
                          System.out.println(totalTotal);     
    }     The code does compile but has a NullPointerException error in line stated above - do u know why??
    Thanks in advance

    Cheers for the reply codeCraig,
    I have changed the code to the below and the NullPointerException is still pointing at the same line, can anyone help me with this:
    public void getOrderTotal() {
              int count = table.getRowCount();
              Vector totalTotal = new Vector();
              for (int i = 0; i < count; i++) {
                   if (table.getValueAt(i,4)== "") {
                   else {
                        BigDecimal price =(BigDecimal)(table.getValueAt(i,3));               
                        String qty = (String)(table.getValueAt(i,4));
                        BigDecimal totalled = price.multiply(new BigDecimal(qty));
                        try {
                        totalTotal = totalTotal.add(totalled);
                        catch (Exception e) {
                             System.out.println(e.getMessage());
                             e.printStackTrace();
                        table.setValueAt(totalled,i,5);
                        System.out.println(price+"\t"+qty+"\t"+totalled);     
                   System.out.println(totalTotal);
         }     Peace

  • Error  while assigning resultset value to Querytable variable in Coldfusion 10

    We are upgrading from coldfusion 8 to 10. Internally we were using java function to to get the data.
    In java function we have a resultset object, if we assign this resultset value to Querytable variable, we are getting below error. This code was working fine in coldfusion 8.
    Detail    This exception is usually caused by service startup failure. Check your server configuration.
    Message    The Runtime service is not available.
    StackTrace    coldfusion.server.ServiceFactory$ServiceNotAvailableException: The Runtime service is not available. at coldfusion.server.ServiceFactory.getRuntimeService(ServiceFactory.java:117) at coldfusion.runtime.RequestMonitor.<clinit>(RequestMonitor.java:14) at coldfusion.sql.QueryTable.populate(QueryTable.java:358) at coldfusion.sql.QueryTable.populate(QueryTable.java:283) at coldfusion.sql.QueryTable.<init>(QueryTable.java:96) at com.myCompany.myClass.myFunct(myClass.java:627) at
    Here is the function which is causing error.
    static private QueryTable myFunct(String userId, SessionFactory sf) {
            PreparedStatement pStmt = null;
            ResultSet rs = null;
            QueryTable ret = null;
             try{
                Query q = sf.getCurrentSession().getNamedQuery("ListUsers");
                pStmt = sf.getCurrentSession().connection().prepareStatement(q.getQueryString());
                rs = pStmt.executeQuery();// works fine till here
                ret = new QueryTable(rs);  // error line         
                rs.close();
            }catch(Exception e){
                e.printStackTrace();
                throw new RuntimeException(e.getLocalizedMessage());
            return ret;
    Can you provide some help on this. Please let me know if you need any other details.

    We have found this error is logs
    coldfusion.runtime.Encryptor$InvalidParamsForEncryptionException: An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same..
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:303)
        at coldfusion.runtime.Encryptor.decrypt(Encryptor.java:284)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5353)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5326)
        at coldfusion.runtime.CFPage.Decrypt(CFPage.java:5458)
        at com.vmware.vcp.service.impl.EncryptColdFusionImpl.decrypt(EncryptColdFusionImpl.java:65)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.initEmailService(ApplicationConfigSer vlet.java:119)
        at com.vmware.vcp.web.servlet.ApplicationConfigServlet.init(ApplicationConfigServlet.java:51 )
        at javax.servlet.GenericServlet.init(GenericServlet.java:160)
        at coldfusion.bootstrap.ClassloaderHelper.initServletClass(ClassloaderHelper.java:121)
        at coldfusion.bootstrap.BootstrapServlet.init(BootstrapServlet.java:59)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5001)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5278)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

  • How to find the value of a variable in other program

    How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
    Regards
    Vin

    Hi Vinayak,
         you will be having your first program values in internal table or some variables,
        when you are calling the second program you wii use like this,
        SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
                           WITH s_emp(second program select-options)   IN t_emp(first program variables)
                           WITH p_chk   EQ t_chk
                           WITH p_r1    EQ t_r1
                           WITH p_month EQ t_month
                           WITH s_cust1 IN t_cust1
                           WITH p_r2    EQ t_r2
                           WITH s_cust2 IN t_cust2
                           WITH s_week  IN t_week
                           AND RETURN.
    you have pas like this to get your first program details.

  • Displaying the value of an variable on the stage

    I have managed to display the values contained in string variables on stage, and I am happy with that, however when I wish to display the value of an int and convert it to a string as one is supposed to do the output to the stage just calls it [class int] and does not give its value. any suggestions?
    My rogram contains a stage at frame 1 which displays a word. The user must input a word. Frame 30 then displays the word which was displayed and the word input by the user. That all works fine. But the value of the variable NumberRight, which has been assigned to that variable will only display as [class int] without showing its value. (even though I have converet it to a string using the .to string function you see below).
    My code is as follows;
    trace( "The number correct was" + NumberRight); //This works fine in the output window and shows the value of the variable as NumberRight [class int]1 (showing the value to be 1)
    outputText.appendText("in/"+textAtIN); //this works fine displaying the word presented and word input by user as in/in
    outputText.appendText( NumberRight.toString(     )); //here lies the problem as it just displays [class int] and nothing else.
    Yes I have managed to overcome that problem it was some code on the first frame, please excuse, however, now, is there any way to remove the [class int] bit from the displays, I wish to have the results as a clear copy of the results so that they can be printed out, without [class int] all over the place?

    Hi Ned thanks for that. Yes I had accidently created blank spaces in the String() argument. (wanted to check if there was a subsequent difference in display and forgot to return them to normal ...Sorted )
    Your next suggestion has eliminated the [class int] but I get a value now of 0.
    My code on the first frame for a correct response for example is;
    function keyPressedIN(event:KeyboardEvent):void
              if (event.keyCode == 13)/*Normally,this will move straight on to the next frame-
              recording a correct response and all that that implies in terms of scores etc. But now I have re directed it to Frame 30 to check are the variables working properly*/
                        //insert code for correct responses vowels etc.
                        VowelI = VowelI+1;
                        NumberRight = NumberRight +1;
                        stage.focus = stage;
                        //There is no need to display the text box as this is a correct response.
                        pupilsResponseIN.visible = false;
                        mainText.visible = false;
                        gotoAndPlay(30);//at the moment this takes me to the display frame to check if all is ok
    On the first frame when the user say hits the Return key my code assigns the value of +1 to the variable; eg
    NumberRight=NumberRight+1;
    and the value of +1 to the value of VowelI
    VowelI=VowelI+1
    At Frame 30 the code is as follows;
    stop();
    trace( "The number correct was"+ NumberRight);
    outputText.appendText("in/"+textAtIN);
    outputText.appendText( "\n");
    outputText.appendText("Vowels Correct ="+(int(VowelI).toString()));
    outputText.appendText( "\n");
    outputText.appendText("TotalCorrect="+(int(NumberRight).toString()));
    //outputText.appendText( VowelI.toString());
    Now what I am getting  is
    in/in
    Vowels Correct = O
    Total Correct = O
    Yet the trace (output box) records the Number correct as [class int]1 
    many years ago I wrote this same program in Authorware using similar code. I am trying to re write it in FlashCS5 using ActionScript 3 and It take days to solve small problems. I notice also that If for example the user of the program makes an error and I record the error as NumberRight =NumberRight -1 the program records it as Total Correct = NaN .
    I gave up on this a few months back but I am trying again. I think there must be a better way to do this. Variables do not seem to add up or subtract for me at present. no doubt its me thats got it wrong.

  • Fetches more values into one variable

    Hi, inside a cursor loop I'd like to assign, each fetch, a value to a variable, in order, at the end to have a collection of all the values fetched into the same variable.
    The code is the following:
    CREATE OR REPLACE procedure APPS.AAA as
    v_pino varchar2(64);
    CURSOR tks_opened_range IS
    SELECT incident_number AS YP_TKS_OPENED_WITHIN_RANGE FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) BETWEEN 1 AND 11111111111
    AND incident_attribute_2 IN ('ΓΕΝΙΚΗ ΔΙΕΥΘΥΝΣΗ ΤΕΧΝΟΛΟΓΙΑΣ')
    ORDER BY incident_number;
    rec_tks_opened_range tks_opened_range%ROWTYPE;
    begin
    FOR rec_tks_opened_range IN tks_opened_range
    LOOP
    v_pino := rec_tks_opened_range.YP_TKS_OPENED_WITHIN_RANGE;
    DBMS_OUTPUT.PUT_LINE('v_pino: ' || v_pino);
    end loop;
    end AAA;
    This works with the variable v_pino!....but at the end, the value of the variable v_pino is ONLY the last fetched by the cursor.
    Is there a way to declare a variable (or better a collection) or a new type in order to have all the data fetched into this variable and the end of the fetching ?
    I need to know this trick because, after, I have to assign this variable to a pipelined table function.
    Thanks in advance
    Alex
    /

    Great Devang !! Thanks a lot ! It works ! Now I am able to retrieve all the values I need and store them into my variable gino
    I searched on the note you mentioned in your mail in order to pass an array as a variable to a table function (PIPE ROW call), but I didn't find nothing about it.
    Now I explain to you my situation.
    I already implemented a table function that works perfectly. I have 2 cursors declared and 2 PIPE ROW calls.
    FUNCTION statistic_report_2_1 (p_resolv_time_ll varchar2, p_resolv_time_ul varchar2, p_ypiresia varchar2)
    RETURN xxi_statistic_rep_2_1_tab PIPELINED
    IS
    -- CURSORS FOR THE FIRST SHEET - Tickets opened per group and per duration
    -- Cursor for tickets opened within 1 hour --
    CURSOR tks_opened_1_h IS
    SELECT incident_number AS YP_TKS_OPENED_WITHIN_1_HOUR
    FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) < 60
    AND incident_attribute_2 IN (SELECT * FROM TABLE(CAST(xxi_szf_discoverer.ypiresia_values(p_ypiresia) AS xxi_ypiresia_list_tab)))
    ORDER BY incident_number;
    rec_tks_opened_1_h tks_opened_1_h%ROWTYPE;
    -- Cursor for tickets opened between 1 hour and 3 hours --
    CURSOR tks_opened_1_3_h IS
    SELECT incident_number AS YP_TKS_OPENED_BE_1_3_HOURS FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) BETWEEN 60 AND 179
    AND incident_attribute_2 IN (SELECT * FROM TABLE(CAST(xxi_szf_discoverer.ypiresia_values(p_ypiresia) AS xxi_ypiresia_list_tab)))
    ORDER BY incident_number;
    rec_tks_opened_1_3_h tks_opened_1_3_h%ROWTYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    -- FIRST SHEET OPEN CURSORS --
    TICKETS NUMBER OPENED WITHIN 1 HOUR
    FOR rec_tks_opened_1_h IN tks_opened_1_h
    LOOP
    PIPE ROW(stat_rep_2_1_type(
    rec_tks_opened_1_h.YP_TKS_OPENED_WITHIN_1_HOUR
    END LOOP;
    -- TICKETS NUMBER OPENED BETWEEN 1 HOUR AND 3 HOURS --
    FOR rec_tks_opened_1_3_h IN tks_opened_1_3_h
    LOOP
    PIPE ROW(stat_rep_2_1_type(
    ,rec_tks_opened_1_3_h.YP_TKS_OPENED_BE_1_3_HOURS));
    END LOOP;
    RETURN;
    END statistic_report_2_1;
    But, in this way and with this syntax, I obtain for each PIPE ROW call only one field filled each time, because I can’t call 2 cursors in a nested loop together (data duplication);
    For example:
    1st PIPE ROW call : only the first field is filled and into the second I have to put ‘’
    2nd PIPE ROW call : only the second field is filled and into the first I have to put ‘’
    ….and I cant’ call with a single PIPE ROW call two cursor variables…..
    Into a Discoverer report this data layout is really bad (you can imagine with thousand
    of records).
    For this reason I thought to use an array variable (gino) to pass to a single PIPE ROW call outside the cursor loop……but it doesn’t work !!!
    Can you suggest me how to resolve this problem….if it possible ?
    Did I have to declare other TYPE or collection ?
    Thanks you so much
    Alex

  • Not able to get the value of ODI Variable when i pass thru Option

    Hi,
    I have ODI variable called prev_etl_run_date which will hold the last successful etl run date. I want to use the value of this variable in one of my KM step.
    But i don’t want to use directly in my KM. So I passed the variable name thru KM Option.
    I intend to use the variable’s value in the KM step, as shown below:
    <%=odiRef.getOption("MY_OPTION_1")%>
    Here I am expecting the value of the variable, but here I am only getting the variable name only.
    Is there any substitution method available in ODI KM , please help me to solve this issue.
    Thanks
    nidhi

    ODI options are not intended for run time parameters. They are like design choices or debugging flags or parameters that can be specified in code template. Previous ETL run time stamp is hardly a design choice.
    On the other hand, it is really a bad practice to put a variable inside KM directly. That creates a dependency that you can easily avoid by putting a filter using that variable in the interface.

Maybe you are looking for

  • Keyboard trackpad not working

    All of a sudden my keyboard and trackpad don't work on my Macbook. USB keyboards and mice work fine. I took off the keyboard and tried it on another Macbook and it worked fine. Don't know if any recent updates or firmware changes have been done. Any

  • DELETED EMAIL ACCOUNT / DELETED NOTES ON IPHONE5

    Hello, I Just deleted my Universito email account (outlook) from my emails account because I have finished from the University and they closed/deactivated all our email accounts. However, I did not realise that some notes were associated with it, so

  • How to display Date in iPad

    Can anyone tell how to display the Date in iPad ? I can see only time being displayed currently.

  • Help inserting js into dreamweaver cs3

    I have been using MS Publisher (yeah I know) to design my web pages but now I am slowly learning Dreamweaver CS3. I am redoing a site within which I have used some forms created with Coffeecup Webform Bilder. It took me a bit to figure out how to ins

  • Error while installing PIM Sync

    Hi, While installing PIM Sync an error is given "Installation found another product installed which uses the same configuration file settings. Installation was cancelled because they cannot function on the same computer. Please uninstall the other so