Sorting values in array

I have an array of integer values. If my program asks the user to input a
number and they input a number that is not in the array, how would I be able to say which values in the array would add up to that number?
for example:
my array has values of 1,1,2,3,5,8,13
if the user inputs a number that isn't part of this array such as 9 the program would output 5+3+1
this has stumped me for some time

kind of easy, first u have to get ur array ordered like ur example.
public boolean isPartOfArray(int[] x, int y){
for(int i=0;i<x.length;i++){
if(x==y){
return true;}
return false;
public void sumat(int[] x, int y){
public int[] z=new int[x.length);
int n=0;
int count=0;
while(n<y){
z[count]=x[ount];
count++;
n=n+x[count];
if(n==y){
print z
else{
print nothing

Similar Messages

  • Sorting values added to an array

    Hi,
    I've written some code to sort value in an array as I add them, but I can't get it to work properly. So far I have:
    public boolean add(int next)
            int last, temp, previous;
            if (size < 1) // checks whether any values have been added to determine correct value for previous.
                previous = size;
            else
                previous = size - 1;
            if (size < arraySize) //determines whether array is full or not
                last = numberList[previous];
                if (next > last)
                    numberList[size] = next;
                    size++;
                else if (next < last)
                    temp = last;
                    numberList[previous] = next;
                    numberList[size] = temp;
                    size++;
                numberAdded = true;
                return numberAdded;
            }Which does add the numbers, but they aren't arranged into the proper order. When I look over it I can't see anything that stands out as being wrong, so I was wondering whether anybody could see anything?
    Thanks for your help,

    endasil wrote:
    nickd_101 wrote:
    I don't want a loop in this case, as i want to put the values into the correct position (with respect to the previous one) as they're added into the array. Basically, my idea is that the previous value is checked against the new value and then they are swapped if the previous value is larger than the new or kept as is if not.So you're saying that if you added
    1, 2, 4, 5, 3
    you'd want the resultant order to be
    1, 2, 4, 3, 5?
    Because by your logic that's what would happen. The most that can ever happen by your logic is that a new entry would be at most 1 away from the end of the array.
    P.S. use an SortedSet, given that your code doesn't allow duplicate values anyway.
    Edited by: endasil on Nov 19, 2007 2:15 PMThanks for the response. What I meant is that I would eventually want it in ascending order 1,2,3,4,5. What I thought I was doing was sorting the comparing the new value with the preceding everytime a number was added so that it would always go in consecutive order. So, for example say the numbers were added to the array one by one in the order 3,5,4,1,2; 3 would be compared to 5 and there would be no change in the position. As i've typed this out i've just realised the massive logical error i've made! Could you point me in the right direction to get this to work as i'm new to this. I've managed to get a pre-defined array sorting as normal, but for this i need to sort everytime I add a new value?
    Thanks again

  • Newbie trying to sort 2D string array

    Dear all,
    After read some book chapters, web sites including this, I still don't get the point.
    If I have a file like,
    1 aaa 213 0.9
    3 cbb 514 0.1
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    and I load into memory as a String[][]
    here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
    * Sort for a 2D String array
    * @param a an String 2D array
    * @param column column to be sort
    public static void sort(String[][] a, int column) throws Exception {
    QuickSort(a, 0, a.length - 1, column);
    /** Sort elements using QuickSort algorithm
    static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
    int lo = lo0;
    int hi = hi0;
    int mid;
    String mitad;
    if ( hi0 > lo0) {
    /* Arbitrarily establishing partition element as the midpoint of
    * the array.
    mid = ( lo0 + hi0 ) / 2 ;
    mitad = a[mid][column];
    // loop through the array until indices cross
    while( lo <= hi ) {
    /* find the first element that is greater than or equal to
    * the partition element starting from the left Index.
    while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
    ++lo;
    /* find an element that is smaller than or equal to
    * the partition element starting from the right Index.
    while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
    --hi;
    // if the indexes have not crossed, swap
    if( lo <= hi )
    swap(a, lo, hi);
    ++lo;
    --hi;
    /* If the right index has not reached the left side of array
    * must now sort the left partition.
    if( lo0 < hi )
    QuickSort( a, lo0, hi, column );
    /* If the left index has not reached the right side of array
    * must now sort the right partition.
    if( lo < hi0 )
    QuickSort( a, lo, hi0, column );
    * swap 2D String column
    private static void swap(String[][] array, int k1, int k2){
    String[] temp = array[k1];
    array[k1] = array[k2];
    array[k2] = temp;
    ----- end of the code --------
    if I call this from the main module like this
    import MyUtil.*;
    public class kaka
    public static void main(String[] args) throws Exception
    String[][]a = MyUtil.fileToArray("array.txt");
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,1);
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,3);
    MyMatrix.printf(a);
    for the first sorting I get
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bba 111 7.1
    9 bbc 417 10.4
    3 cbb 514 0.1
    8 dee 887 2.1
    (lexicographic)
    but for the second one (column 3) I get
    3 cbb 514 0.1
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
    I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
    I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
    Any help will be deeply appreciated
    Thanks for your help and your attention
    Pedro

    public class StringArrayComparator implements Comparator {
      int sortColumn = 0;
      public int setSortColumn(c) { sortColumn = c; }
      public int compareTo(Object o1, Object o2) {
        if (o1 == null && o2 == null)
          return 0;
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        String[] s1 = (String[])o1;
        String[] s2 = (String[])o2;
        // I assume the elements at position sortColumn is
        // not null nor out of bounds.
        return s1[sortColumn].compareTo(s2[sortColumn]);
    // Then you can use this to sort the 2D array:
    Comparator comparator = new StringArrayComparator();
    comparator.setSortColumn(0); // sort by first column
    String[][] array = ...
    Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic.

  • Sort and Object array of Arrays

    Hi,
    I have an object array that contains a String[] and an int[].
    Object[String[], int[]]
    The values in the Strings array must be in the same position in the array as those in the int array i.e
    String [0] is the string representation of int[0].
    Its for a bar chart.
    That is all working beautifully.
    Now however I want to sort the int array in descending order by the value of the ints in the array and thus the order or the String array has to mirror this.
    I am using a comparator to do this but it just wont work. I'm sure this is the way but how should it look?
    Has anybody got any ideas?
    Thanks in advance,
    L.

    use the bubblesort:
        for (int i = a.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (a[j][1] > a[j+1][1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
        }

  • Read and sort values present in .ini file

    Hi all,
    I have a .ini file in which a set of modules with there order of execution is mentioned.I want to get all these values sorted as an array so that I can proceed with the execution of each in the order mentioned.The module list in the .ini file looks like this:
    Here, digits represent the order of execution of module.
    I should get output as an array with following values:
    1 MNO
    2 DEF
    3 STU
    4 PQR
    5 GHI
    6 VWZ
    7 ABC
    8 JKL
    I know about config data and read key vis but since the module list is huge I dont know how to write an efficient code for this.All suggestions are welcome.
    Thanks.
    Solved!
    Go to Solution.

    The snippet below should be very close to what you want.

  • About the sort method of arrays

    Hi,
    I found that for primitive types such as int, float, etc., algorithm for sort is a tuned quicksort. However the algorithm for sorting an object array is a modified merge sort according to the java API. What is the purpose of using two different sorting strategy?
    Thanks.

    The language knows how to compare two ints, two doubles, etc. For Object arrays, however, it's not a simple matter of comparing two reference values as ints or longs. We're not comparing the references. We have to compare the objects, according to the class's compareTo() method (if it implements Comparable) or a provided Comparator. The size of an int is known, fixed, and small. The size of an object is unknown, variable, and essentially unbounded. I don't know for sure that that difference is what drove the different approaches, but it is a significant difference, and mergesort is better suited to use cases where we can't fit the entire array into memory at one time. It seems reasonable that we'd get better locality of reference (fewer cache misses, less need to page) with an array of ints than with an array of objects.
    Edited by: jverd on Mar 18, 2011 3:16 AM

  • Sorting between multiple arrays.

    I thought that I had posted this yesterday; however as I can not find my post...
    I need assistance with part of a project where I need to sort between multiple arrays; using one of the columns as the sort criteria. The arrays contain integers, strings, and doubles; however I would like to sort and display the arrays alphabetically using the string column. I was told that a bubble array may work, however as I can not find specific information on the use of a bubble array, I really don't know where to start. The arrays look like the following:
    productArray[0] = new Product(1, "binder ", 15, 1.5, 0, 0);
    productArray[1] = new Product(2, "marker ", 13, .5, 0, 0);
    productArray[2] = new Product(3, "paper ", 24, .95, 0, 0);
    productArray[3] = new Product(4, "pen ", 5, .25, 0, 0); \
    Any assistance that anyone could provide would be greatly appreciated. I am a newbie when it comes to Java and the course materials are extremely vague.
    Dman

    Thank you for your assistance.
    The site that I found to be most helpful was the http://www.onjava.com/lpt/a/3286 site; however I am still experiencing problems. I have added code to the program as noted below:
    public class Inventoryprogrampart3
    /** Creates a new instance of Main */
    * @param args the command line arguments
    public static void main(String[] args)
    // create Scanner to obtain input from command window
    java.util.Scanner input = new java.util.Scanner( System.in );
    double totalInventoryValue = 0;
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    System.out.println(); // Displays a blank line
    System.out.println( " Welcome to the Inventory Program - Part 2 " ); // Display the string
    System.out.println( " ----------------------------------------- " ); // displays a line of characters
    System.out.println(); // Displays a blank line
    System.out.println( "This program will output an office supply inventory" ); // Display the string
    System.out.println( "listing that includes item numbers for the" ); // Display the string.
    System.out.println( "inventoried products, the items product names, the" ); // Display the string.
    System.out.println( "quantity of each product in stock, the unit price" ); // Display the string
    System.out.println( "for each product, the total value of each products" ); // Display the string
    System.out.println( "inventory, and a total value of the entire inventory." ); // Display the string
    System.out.println(); // Displays a blank line
    System.out.println( "*****************************************************" ); // Displays a line of characters
    System.out.println(); // Displays a blank line
    Product[] productArray = new Product[ 7 ]; // creates 7 product arrays
    // adds data to the 7 arrays
    productArray[0] = new Product();
    productArray[0].setitemNumber(1);
    productArray[0].setproductName ( "binder" );
    productArray[0].setitemQuantity(15);
    productArray[0].setitemPrice(1.5);
    productArray[0].setinventoryValue(0);
    productArray[1] = new Product();
    productArray[1].setitemNumber(2);
    productArray[1].setproductName( "paper" );
    productArray[1].setitemQuantity(24);
    productArray[1].setitemPrice(.95);
    productArray[1].setinventoryValue(0);
    productArray[2] = new Product();
    productArray[2].setitemNumber(4);
    productArray[2].setproductName( "pen" );
    productArray[2].setitemQuantity(5);
    productArray[2].setitemPrice(.25);
    productArray[2].setinventoryValue(0);
    productArray[3] = new Product();
    productArray[3].setitemNumber(3);
    productArray[3].setproductName( "marker" );
    productArray[3].setitemQuantity(13);
    productArray[3].setitemPrice(.5);
    productArray[3].setinventoryValue(0);
    productArray[4] = new Product();
    productArray[4].setitemNumber(5);
    productArray[4].setproductName( "pencil" );
    productArray[4].setitemQuantity(28);
    productArray[4].setitemPrice(.4);
    productArray[4].setinventoryValue(0);
    productArray[5] = new Product();
    productArray[5].setitemNumber(7);
    productArray[5].setproductName( "tape" );
    productArray[5].setitemQuantity(14);
    productArray[5].setitemPrice(1.65);
    productArray[5].setinventoryValue(0);
    productArray[6] = new Product();
    productArray[6].setitemNumber(6);
    productArray[6].setproductName( "staples" );
    productArray[6].setitemQuantity(13);
    productArray[6].setitemPrice(1.25);
    productArray[6].setinventoryValue(0);
    System.out.println( "Inventory listing prior to sorting by product name:" );
    System.out.println(); // Displays a blank line
    System.out.println( "Item #"+"\t"+"Product Name"+"\t"+"Stock"+"\t"+"Price"+"\t"+"Total Value"); // Displays a header line for the inventory array display
    System.out.println(); // Displays a blank line
    System.out.println( "-----------------------------------------------------" ); // Displays a line of characters
    System.out.println(); // Displays a blank line
    for (int i=0; i<=6; i++)
    Product products = productArray;
    String productName = products.getproductName();
    int itemNumber = products.getitemNumber();
    int itemQuantity = products.getitemQuantity();
    double itemPrice = products.getitemPrice();
    double inventoryValue = products.getinventoryValue();
    System.out.println( productArray[i].getitemNumber() +"\t"+ productArray[i].getproductName() +"\t"+"\t" + productArray[i].getitemQuantity() +"\t"+ nf.format(productArray[i].getitemPrice()) +"\t"+ nf.format(productArray[i].getinventoryValue()) );
    Arrays.sort(productArray);
    System.out.println( "-----------------------------------------------------" ); // Displays a line of characters
    System.out.println(); // Displays a blank line
    System.out.println( "Inventory listing after being sorted by product name:" );
    System.out.println(); // Displays a blank line
    System.out.println( "Item #"+"\t"+"Product Name"+"\t"+"Stock"+"\t"+"Price"+"\t"+"Total Value"); // Displays a header line for the inventory array display
    System.out.println(); // Displays a blank line
    System.out.println( "-----------------------------------------------------" ); // Displays a line of characters
    for(int i=0; i <= 6; i++)
    totalInventoryValue = totalInventoryValue + productArray[i].getinventoryValue(); // calculates the total value of the entire products inventory
    System.out.println( productArray[i].getitemNumber() +"\t"+ productArray[i].getproductName() +"\t"+"\t"+ productArray[i].getitemQuantity() +"\t"+ nf.format(productArray[i].getitemPrice()) +"\t"+ nf.format(productArray[i].getinventoryValue()) );
    }// end for
    System.out.println(); // Displays a blank line
    System.out.println( "The total value of the entire inventory is: " + nf.format(totalInventoryValue) ); // Displays the entire inventory value
    System.out.println(); // Displays a blank line
    System.out.println( "*****************************************************" ); // Displays a line of characters
    } // end public static void main
    }// end public class Inventoryprogrampart3 main
    The following utilities have been set:
    import java.io.*;
    import java.text.*;
    import java.util.Scanner;
    import java.util.*;
    import java.util.Arrays;
    import java.util.ArrayList;
    import java.util.Comparator;
    The program compiles, however when I try to run the program I receive the following error (which outputs about 1/2 way through the program:
    Exception in thread "main" java.lang.ClassCastException: Product can not be cast to java language comparable.
    (along with a listing of other errors - I can't even get my cut and paste to work on my command prompt window).
    I've tried about 50 different iterations and nothing seems to work.

  • How to display the sort value in the selection screen in the report title

    Dear All,
    How to display the sort value in the selection screen in the report title? I have selected a value in the selection screen for sorting , but i need that values by which i have sorted with in the report title. Can you please throw some light on this!!
    Good day,
    Thanks and regards
    Arun S

    Hi Arun,
    Try this.
    1, Set one dynamic parameter,
    2, Drag and drop that parameter into  your report title.
    3, Pass the value(sort value) dynamically from your application,
    4, Cheers..
    Other wise Try with Dataset, create a dataset and fill thev alue into that.. Then  set the data source from CR designer. and darg and drop that data column into the report.
    Hope this will work,
    Regards,
    Salah
    Edited by: salahudheen muhammed on Mar 25, 2009 11:13 AM

  • Assigning values to array in soa 10.1.3

    Dear team,
    I am working on soa10.1.3 server. we have a complex element of string array.we created a varaible of that element. In while loop we need to pass values to array elements.How can we do that..we tried with indexvaraible..but getting error.
    Regards,
    Radha

    schema is
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/BPELProcess4"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="BPELProcess4ProcessRequest">
              <complexType>
                   <sequence>
                        <element name="input" type="string"/>
                   </sequence>
              </complexType>
         </element>
         <element name="BPELProcess4ProcessResponse">
              <complexType>
                   <sequence>
                        <element name="result" type="string"/>
                   </sequence>
              </complexType>
         </element>
    <element name="element5">
    <complexType>
    <sequence>
    <element name="result" minOccurs="0" maxOccurs="unbounded"
    type="string"/>
    </sequence>
    </complexType>
    </element>
    </schema>
    wdsl is
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="BPELProcess4"
    targetNamespace="http://xmlns.oracle.com/BPELProcess4"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:client="http://xmlns.oracle.com/BPELProcess4"
    xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/">
         <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         TYPE DEFINITION - List of services participating in this BPEL process
         The default output of the BPEL designer uses strings as input and
         output to the BPEL Process. But you can define or import any XML
         Schema type and use them as part of the message types.
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         <types>
              <schema xmlns="http://www.w3.org/2001/XMLSchema">
                   <import namespace="http://xmlns.oracle.com/BPELProcess4" schemaLocation="BPELProcess4.xsd" />
              </schema>
         </types>
         <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         MESSAGE TYPE DEFINITION - Definition of the message types used as
         part of the port type defintions
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         <message name="BPELProcess4RequestMessage">
              <part name="payload" element="client:BPELProcess4ProcessRequest"/>
         </message>
         <message name="BPELProcess4ResponseMessage">
              <part name="payload" element="client:BPELProcess4ProcessResponse"/>
         </message>
    <message name="BPELProcessMessage">
              <part name="payload" element="client:element5"/>
         </message>
         <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         PORT TYPE DEFINITION - A port type groups a set of operations into
         a logical service unit.
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         <!-- portType implemented by the BPELProcess4 BPEL process -->
         <portType name="BPELProcess4">
              <operation name="initiate">
                   <input message="client:BPELProcess4RequestMessage"/>
              </operation>
         </portType>
         <!-- portType implemented by the requester of BPELProcess4 BPEL process
         for asynchronous callback purposes
         -->
         <portType name="BPELProcess4Callback">
              <operation name="onResult">
                   <input message="client:BPELProcess4ResponseMessage"/>
              </operation>
         </portType>
         <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         PARTNER LINK TYPE DEFINITION
         the BPELProcess4 partnerLinkType binds the provider and
         requester portType into an asynchronous conversation.
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         <plnk:partnerLinkType name="BPELProcess4">
              <plnk:role name="BPELProcess4Provider">
                   <plnk:portType name="client:BPELProcess4"/>
              </plnk:role>
              <plnk:role name="BPELProcess4Requester">
                   <plnk:portType name="client:BPELProcess4Callback"/>
              </plnk:role>
         </plnk:partnerLinkType>
    </definitions>
    bpel file is
    <?xml version = "1.0" encoding = "UTF-8" ?>
    <!--
    Oracle JDeveloper BPEL Designer
    Created: Fri Aug 27 10:01:38 IST 2010
    Author: ruck
    Purpose: Asynchronous BPEL Process
    -->
    <process name="BPELProcess4"
    targetNamespace="http://xmlns.oracle.com/BPELProcess4"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:ns4="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
    xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ns3="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns2="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:client="http://xmlns.oracle.com/BPELProcess4"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <!--
    PARTNERLINKS
    List of services participating in this BPEL process
    -->
    <partnerLinks>
    <!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:BPELProcess4"
    myRole="BPELProcess4Provider"
    partnerRole="BPELProcess4Requester"/>
    </partnerLinks>
    <!--
    VARIABLES
    List of messages and XML documents used within this BPEL process
    -->
    <variables>
    <!-- Reference to the message passed as input during initiation -->
    <variable name="inputVariable"
    messageType="client:BPELProcess4RequestMessage"/>
    <!-- Reference to the message that will be sent back to the requester during callback -->
    <variable name="outputVariable"
    messageType="client:BPELProcess4ResponseMessage"/>
    <variable name="elementMessage"
    messageType="client:BPELProcessMessage"/>
    <variable name="count" type="xsd:int"/>
    </variables>
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    -->
    <sequence name="main">
    <!-- Receive input from requestor. (Note: This maps to operation defined in BPELProcess4.wsdl) -->
    <receive name="receiveInput" partnerLink="client"
    portType="client:BPELProcess4" operation="initiate"
    variable="inputVariable" createInstance="yes"/>
    <!--
    Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
    -->
    <assign name="Assign_1">
    <copy>
    <from expression="number(1)"/>
    <to variable="count"/>
    </copy>
    </assign>
    <while name="While_1"
    condition="bpws:getVariableData('count') &lt;= number(5)">
    <assign name="Assign_2">
    <copy>
    <from expression="'value'"/>
    <to variable="elementMessage" part="payload"
    query="/client:element5/client:result[bpws:getVariableData('count')]"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('count')+number(1)"/>
    <to variable="count"/>
    </copy>
    </assign>
    </while>
    <invoke name="callbackClient" partnerLink="client"
    portType="client:BPELProcess4Callback" operation="onResult"
    inputVariable="outputVariable"/>
    </sequence>
    </process>
    For the count 1 code is working fine.. for count=2 thrwoing exception
    <while>
    Assign_2
    [2010/08/27 10:23:20] Updated variable "elementMessage" less
    -<elementMessage>
    -<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    -<element5 xmlns="http://xmlns.oracle.com/BPELProcess4">
    <result>value
    </result>
    </element5>
    </part>
    </elementMessage>
    [2010/08/27 10:23:20] Updated variable "count" More...
    <count>2
    </count>
    Assign_2
    [2010/08/27 10:23:20] Error in <assign> expression: <to> value is empty at line "86". The XPath expression : "" returns zero node, when applied to document shown below: More...
    [2010/08/27 10:23:20] "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown. More...
    </while>
    </sequence>
    [2010/08/27 10:23:20] "BPELFault" has not been caught by a catch block.
    [2010/08/27 10:23:20] There is a system exception while performing the BPEL instance, the reason is "faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure} messageType: {} parts: {{summary=XPath query string returns zero node. According to BPEL4WS spec 1.1 section 14.3, The assign activity &lt;to&gt; part query should not return zero node. Please check the BPEL source at line number "86" and verify the &lt;to&gt; part xpath query. Possible reasons behind this problems are: some xml elements/attributes are optional or the xml data is invalid according to XML Schema. To verify whether XML data received by a process is valid, user can turn on validateXML switch at the domain administration page. }} ". Please check the error log file for more infromation. Please try to use bpel fault handlers to catch the faults in your bpel process. If this is a system exception, please report this to your system administrator. Administrator could perform manual recovery of the instance from last non-idempotent activity or dehydration point. More...
    [2010/08/27 10:23:20] BPEL process instance #"60002" cancelled

  • How to pass value in array to another procedure?

    Hello.
    I have created application by Developer form9i.
    And I have some problem about passing value in array to another procedure.
    My code is :
    PROCEDURE p_add_array (col_no in number,
    col_val in varchar2) IS     
    type xrecord is record(col number,vcol varchar2(1000));
    xrec xrecord;
    type varraytype is varying array(42) of xrecord;     
    xvartab varraytype := varraytype();
    alert number;
    BEGIN
    set_application_property(cursor_style,'busy');
    xrec.col := col_no;
    xrec.vcol := col_val;
    xvartab.extend(1);
    xvartab(col) := xrec;
    EXCEPTION
    when others then
    set_application_property(cursor_style,'default');
    alert := f_show_alert('!Error ORA-'||
    to_char(DBMS_ERROR_CODE)||' '||
    substr(DBMS_ERROR_TEXT,1,240),
    'al_stop');          
    END;
    And I want to have
    PROCEDURE p_print_arrey is
    BEGIN
    END;
    So how to bring value of xvartab( ) in p_add_array to use in p_print_array?
    Anybody please help me solve this ploblem.

    Hi,
    Instead of declaring the array locally within the procedure (i.e. p_add_array), define it in the package specification (i.e. Under Program Units).
    -- Shailender Mehta --

  • ORDER BY values in array

    Hello dear colleagues,
    Is it possible to sort values by values in IN clause.
    In MySQL there is a function called FIELD (http://stackoverflow.com/questions/866465/sql-order-by-the-in-value-list)
    For example:
    SELECT * FROM <tab>
    WHERE "attribute" IN ('val1', 'val2', 'val3')
    ORDER BY FIELD( "attribute", 'val1', 'val2', 'val3');
    If it isn't possible how can I do it with SQLScript?

    Hi Michael,
    I don't think HANA has such sort ordering specification by values as you mentioned. May be, you can try the alternatives as mentioned on the discussion thread itself.
    You can try something like mentioned below, but I am not sure if it is a scalable solution.
    Regards,
    Ravi

  • What types of sort performed by sort method of Array class ?

    I use normal bubble sort and method Array.sort() to sort some given data of an Array and then count the time.But Array.sort() method takes more time then normal bubble sort.
    Can anybody tell me what types of sort performed by sort method of Array class?

    I'm pretty sure that in eariler versions (1.2, 1.3
    maybe?) List.sort's docs said it used quicksort. Or I
    might be on crack.You are actually both correct, and wrong :)
    From the documentation of the sort methods hasn't changed in 1.2 -> 1.4 (as far as I can notice), and the documentation for sort(Object[]) says (taken from JDK 1.2 docs):
    "This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
    The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists."
    So, how could you be correct? The documentation for e.g. sort(int[]) (and all other primities) says:
    "Sorts the specified array of ints into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance."
    Your memory serves you well :)
    /Kaj

  • PLD sorting values

    Hello
    I have a question
    End of the mmonth we make an invoice combining all delivery notes
    On the PLD I have storted Delivery Note number on the repetitive area (sort value) but in the same group I want the date and document reference remark to appear
    I have sometimes the date and the ref text but sometimes not so the solution I have is not correct
    I have made a link fields as a formula for date and base ref
    Field 1 = Doc Base number of the row INV1
    Field 2 = Sorted value
    Formula : Field1==Field2
    The date and base ref are linked to Formula above...
    Maybe there should be another way to have everytime date and base ref to be shown in the group 1 area

    Hello gordon
    No I have not tried but to me create UDF fields which have the same information as regular field makes no sense
    What would be the advantage ?
    What UDF you mean date and doc reference right ?

  • Need to sort an object array using an element in the object.

    hi all,
    i need to sort an object array using an element in the object.can someone throw some light on this.
    Edited by: rageeth on Jun 14, 2008 2:32 AM

    [http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html]

  • Shifting positions of values in arrays

    I need to replicate some functionality in existing IDL (Interactive Data Language) code. This language has some very high level constructs for moving values in arrays. This statement:
    shifted_array = shift(my_array, xshift, yshift)shift all the values in my_array in the x direction by xshift and all the values in the y direction by yshift (and wraps the values around) and puts them in shifted_array.
    How would I best implement this in Java? That is, do it row-by-row / column-by-column / element-element? If so, does anybody have such code already? If not, is there some 'higher-level' way to do this? or use some other data structure?
    Message was edited by:
    allelopath

    Most of the functionality you describe is in
    arraycopy(Object, int, Object, int, int) - Static method in class java.lang.System
    Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.
    You need to handle the wraparound.

Maybe you are looking for