An array and scalar values together in an sql statement

Hi
We have a table called SERVICE and following are the 3 columns from SERVICE table,
SERVICESTATUSID - NUMBER(10)
ACCOUNTID - NUMBER(10)
SERVICENUMBER - VARCHAR(41)
My aim is to be able to update the status of a bunch of entries in this table from Pro C code with new ServiceStatusID where accountId matches the accountId supplied and SERVICENUMBER exists in the list of services supplied.
Now I am trying to use host arrays here for SERVICENUMBERs and then my Update statement looks like this,
UPDATE SERVICE SET SERVICESTATUSID = :x WHERE ACCOUNTID = :y AND SERVICENUMBER = :z
And then I am trying to execute it with the help of bind variables in Pro C as follows,
EXEC SQL AT DB_NAME CONTEXT USE :myContext;
EXEC SQL AT DB_NAME DECLARE sqlStatement STATEMENT;
EXEC SQL AT DB_NAME PREPARE sqlStatement FROM :str;
EXEC SQL AT DB_NAME EXECUTE sqlStatement USING :statusId, :accountId, :serviceNumbersList;
where statusId is integer,

user12169137 wrote:
Now I am trying to use host arrays here for SERVICENUMBERs and then my Update statement looks like this,
UPDATE SERVICE SET SERVICESTATUSID = :x WHERE ACCOUNTID = :y AND SERVICENUMBER = :z
And then I am trying to execute it with the help of bind variables in Pro C as follows,
EXEC SQL AT DB_NAME CONTEXT USE :myContext;
EXEC SQL AT DB_NAME DECLARE sqlStatement STATEMENT;
EXEC SQL AT DB_NAME PREPARE sqlStatement FROM :str;
EXEC SQL AT DB_NAME EXECUTE sqlStatement USING :statusId, :accountId, :serviceNumbersList;
where statusId is integer,I am not sure what you are asking. I think you want statusId to be a scalar integer but use a series of values for the service numbers.
This can be done, but will take a little effort. It might be most easily done in a PL/SQL block where you can control the datatypes too. What you will have to do is create a database object with the datatype (integer, number, whatever), then another object as a table of that object. It should then be possible to convert your collection into a database nested table with the CAST() function. Don't expect really good performance from this.
Search OTN for cast conversions for more information on this method.
Another alternative if you have < 1000 items is to use dynamic SQL by generating an IN list from your collection contents. Again, performance will probably not be great.
Good luck.

Similar Messages

  • Transfering elements to new array and doubling values.

    Hi my problem is that I need to ask a user to enter 5 integers that stores them in an array. Transfer them to a new array by doubling the values when trasferred.
    Please help I have 3 errors.
    class arrays
         public static void main (String[] args)
              int numbers[] = new int [5];
              byte array1Size = 0;
              int input = 0;
              char goon = 'y';
                   //create and initialise an array of 5 integers
                   int array1[] = new int [5];
                   // loop and fill each element
                   for (int x = 0; x < array1.length; x++)
                        System.out.println("Enter a number: ");
                        array1[x] = EasyIn.getInt();
                        // Filling array
                        if (array1Size >= array1.length)
                             //Make a new array doubling the values od the integers
                             int array2 [] = new int [2 * array1.length]; // 10 integers
                             //Copying integers
                             System.arrayCopy (array1, 0, array2, 0, array1.length);
                             //Make old reference point to new array
                             array1 = array2;
                        else
                             //normal
                             do
                                  System.out.print("Enter an integer: ");
                                  input = EasyIn.getInt();
                                  anotherArray[anotherArraySize] = input;
                                  anotherArraySize++;
                                  System.out.print ("Another number? Enter Y or N: ");
                                  goon = EasyIn.getChar();
                             }     while(goon = = 'y' | goon = = 'Y');
    the errros >>>
    G:\Java\Practical 7\Practical74.java:33: '.class' expected
                             int array2 [] = new int [2 * array1.length]; // 10 integers
    ^
    G:\Java\Practical 7\Practical74.java:33: not a statement
                             int array2 [] = new int [2 * array1.length]; // 10 integers
    ^
    G:\Java\Practical 7\Practical74.java:41: 'else' without 'if'
                        else
    ^
    3 errors
    Tool completed with exit code 1
    Thanks

    Hi,
    it seems you forgot the curly braces in the if-else statement:
    if (array1Size >= array1.length){
    //Make a new array doubling the values od the integers
    int array2 [] = new int [2 * array1.length]; // 10 integers
    //Copying integers
    System.arrayCopy (array1, 0, array2, 0, array1.length);
    //Make old reference point to new array
    array1 = array2;
    else{
    //normal
    do
    System.out.print("Enter an integer: ");
    input = EasyIn.getInt();
    anotherArray[anotherArraySize] = input;
    anotherArraySize++;
    System.out.print ("Another number? Enter Y or N: ");
    goon = EasyIn.getChar();
    } while(goon = = 'y' | goon = = 'Y');
    }

  • Build Array and Output Values to Text or Excel File

    I know this is a simple question but I need some help. I'm reading a DC voltage in LabVIEW a while loop. I want to store all the read values into an array and export that array as an text or Excel file. I had a VI that I build before for this but I cannot seem to find it and I can't remember how I did it before. Any help is appreciated. I think I can do the exporting part but I do help with building the array (storing all the data values).

    I run into a problem while using the "Write to Text File Function". Initially I took about 60 measurements and wrote to a text file. That works but I increased the amount of measurements to be taken to 600 and when I did that the output in the text file are all Chinese letters (or that's what it seems like). Is this because I'm writing too much data?
    When I use the "Write To Spreadsheet File VI" to write the measurments it works fine for the 600 measurements. The problem with this is I cannot insert any text. Using the "Write to Text File Function" I inserted some text before the measurements and "end of lines", to format the data. Attached is a screenshot of my VI.
    Attachments:
    measurements.PNG ‏45 KB

  • Getting difference from values of two different SQL Statements

    Hello,
    I have two SQL Queries like the following:
    1. Statement:
    SELECT name, SUM(a1), SUM(b1),SUM(c1),SUM(d1)
    FROM table 1, table 2
    WHERE ...
    GROUP BY name
    2. Statement:
    SELECT name, SUM(a2), SUM(b2),SUM(c2),SUM(d2)
    FROM table 3, table 4
    WHERE ...
    GROUP BY name
    I need now a combination of these SQL Statements in one Statement where the result should be the following records
    name, a1-a2 as a, b1-b2 as b, c1-c2 as c, d1-d2 as d
    Name is a VARCHAR and in both queries the values of the field name are the same
    all other fields are integer.
    I hope someone can help me.
    Regards

    You can use this
    with t1 as (
              SELECT name, SUM(a1) as a1, SUM(b1) as b1,SUM(c1) as c1,SUM(d1) as d1
              FROM table 1, table 2
              WHERE ...
              GROUP BY name
         ), t2 as (
              SELECT name, SUM(a2) as a2, SUM(b2) as b2,SUM(c2) as c2,SUM(d2) as d2
              FROM table 3, table 4
              WHERE ...
              GROUP BY name     
         ), tt as (
              select name
              from t1
              union
              select name
              from t2
    select *
    from tt
         natural left outer join t1
         natural left outer join t2
    where a1 <> a2
         or b1 <> b2
         or c1 <> c2
         or d1 <> d2Bye Alessandro

  • Find start and end execution time of a sql statement?

    I am have databases with 10.2.0.3 and 9.2.0.8 on HP UNIX 11i and Windows 200x.
    I am not in a position to turn on sql tracing in production environment. Yet, I want to find when a sql statement started executing and when it ended. When I look at v$sql, it has information such FIRST_LOAD_TIME, LAST_LOAD_TIME etc. No where it has information last time statement began execution and when it ended execution.. It shows no of executions, elapsed time etc, but they are cumulative. Is there a way to find individual times (time information each time a sql statement was executed. – its start time, its end time ….)? If I were to write my own program how will I do it?
    Along the same line, when an AWR snapshot is shown, does it only include statements executed during that snapshot or it can have statements from the past if they have not been flushed from shared memory. If it only has statements executed in the snapshot period, how does it know when statement began execution?

    Hi,
    For oracle 10g you can use below query to find start and end time, you can see data for last seven days.
    select min(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "Start time", max(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "End Time", b.sql_text
    from dba_HIST_ACTIVE_SESS_HISTORY a,DBA_HIST_SQLTEXT b where
    a.sql_id=b.sql_id
    order by 1;
    Regards
    Jafar

  • How to send byte array and String values to servlet from Swing application

    Hi all,
    I am new to swing, servlet, and socket connection.
    I have swing application to draw images and some input data. I dont know to send to server.
    byte[] buf = baos.toByteArray();
    URL servletURL = new URL("http://10.70.70.1:8080/servlet/SaveImage)
    URLConnection conn = servletURL.openConnection();
    conn.setDoOutput(true);
    BufferedWriter out = new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
    out.write(buf&a=aaaa&b=bbbbb);
    out.flush();
    out.close();
    can I do like this. Strings are received in server side perfect. but i cant get byte array data. Please help me.
    Thanks in advance.

    <img src="myservlet">
    In your myservlet:
    response.setContentType("image/jpeg");
    then write your image date via ImageIO that uses response output stream.

  • Extracting XML tags and its values using ORACLE PL/SQL

    I need help to create a procedure that receive a XML string and insert it into the table after parsing it.
    If the XML has 10 tags then it should insert into the table 10 rows. Table will be having tag name and value. This will be plain XML tags without attributes in tags.

    Hi,
    I am able to retreive the values of the tags using extract function (example: lv_xml.EXTRACT ('/ROWSET/EMPLOYEE/EMPNO/text()').getstringval() ). But could you help me to find some way to extract the tags also since we have no idea what the tags are and how many tags are there, in advance.
    Anybody's help will be a releif!
    Thanks in advance,
    Leslie
    Message was edited by:
    user544830

  • How to check parsing and binding of procedure's inner sql statements

    Hi,
    I want to check, how all variables binding gets done for the sqls used in procedure.
    Is there any dictionary table or way to get it?
    Thanks in Advance.

    939517 wrote:
    Hi,
    I want to check, how all variables binding gets done for the sqls used in procedure.
    Is there any dictionary table or way to get it?
    Thanks in Advance.query one of the views below
    SQL> select view_name from dba_views where view_name like '%BIND%';
    VIEW_NAME
    V_$SQL_BIND_CAPTURE
    V_$SQL_BIND_DATA
    V_$SQL_BIND_METADATA
    DBA_OPBINDINGS
    USER_OPBINDINGS
    USER_SQLSET_BINDS
    USER_SQLTUNE_BINDS
    ALL_OPBINDINGS
    DBA_HIST_SQLBIND
    DBA_HIST_SQL_BIND_METADATA
    DBA_SQLSET_BINDS
    VIEW_NAME
    DBA_SQLTUNE_BINDS
    KU$_LOBINDEX_VIEW
    KU$_OPBINDING_VIEW
    ALL_SQLSET_BINDS
    GV_$SQL_BIND_CAPTURE
    GV_$SQL_BIND_DATA
    GV_$SQL_BIND_METADATA
    18 rows selected.

  • Assigning values to 2 fields using sql statement

    db11g , apex 4.0 and firefox 24 ,
    hi all ,
    i am trying to follow this tutorial to assign values to 2 items on a page using sql statement ,
    and i am using the same sql statement the tutorial uses
    select d.loc location, count(e.empno) num_employees from dept d, emp e where d.deptno = e.deptno(+) and d.deptno = :P3_DEPTNO group by d.loc -- btw , what does the "+" sign mean?
    after the e.deptno in the where condition .
    but i am facing this error
    1 error has occurred
    Wrong number of columns selected in the SQL query. See Help of attribute for details.
    and it does not work with two columns in the select statement under any conditions , i tried to remove the group function and the group clause ,
    it does not work unless i use only one column in the select statement ??
    thanks

    Pars
    And how exactly is this rewrite of the sql statement resolving the OP's issue.
    You are still using more than 1 column which will still result in the error message:
    Wrong number of columns selected in the SQL query.
    As mentioned in my earlier post APEX 4.0 (the version the OP is using) does not handle a sql statement with multiple columns for the dynamic action Set Value.
    Which means the fastest  and simplest solution is splitting up the dynamic action in multiple Set Value actions.
    Using this plugin or upgrade to a newer apex version would also be a possibility.
    Nicolette

  • How to ask for an array and how to save the values

    I'm supposed to be learning the differences between a linear search and a binary search, and the assignment is to have a user input an array and search through the array for a given number using both searches. My problem is that I know how to ask them how long they want their array to be, but I don't know how to call the getArray() method to actually ask for the contents of the array.
    My code is as follows:
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How long would you like the array to be?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            System.out.println("Please enter the first value of the array");
        public static void getArray(int List[], int arrayLength)
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter the next value for array");
                 List[i] = input.nextInt();
         public static void printArray(int List[])
             for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
    public class search
        public static int binarySearch(int anArray[], int first, int last, int value)
            int index;
            if(first > last) {
                index = -1;
            else {
                int mid = (first + last)/2;
                if(value == anArray[mid]) {
                    index = mid; //value found at anArray[mid]
                else if(value < anArray[mid]) {
                    //point X
                    index = binarySearch(anArray, first, mid-1, value);
                else {
                    //point Y
                    index = binarySearch(anArray, mid+1, last, value);
                } //end if
            } //end if
            return index;
        //Iterative linear search
        public int linearSearch(int a[], int valueToFind)
            //valueToFind is the number that will be found
            //The function returns the position of the value if found
            //The function returns -1 if valueToFind was not found
            for (int i=0; i<a.length; i++) {
                if (valueToFind == a) {
    return i;
    return -1;

    I made the changes. Two more questions.
    1.) Just for curiosity, how would I have referenced those methods (called them)?
    2.) How do I call the searches?
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How many values would you like the array to have?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            //Collects the array information
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter a value for array");
                 List[i] = input.nextInt(); 
            //Prints the array
            System.out.print("Array: ");
            for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
            //Asks for the value to be searched for
            System.out.println("What value would you like to search for?");
            int temp = input.nextInt();
            System.out.println(search.binarySearch()); //not working
    }

  • How to write values to an array and call these to produce an xy graph

    Hi, Hopefully someone can help. I have attahced my VI.
    I am happy with how to write data to a file, which I have already done. The next thing I want to do, is write the pressure and acoustic values to an array for the duration of my testing (Testing is when the log switch is on). Once I switch the log button on my front panel off, I want to be able to call another VI which will display an XY graph of the Pressure and acoustics Vs Time. This will be populated from the array I create. Can anyone please help.
    Thanks in advance.
    Attachments:
    PSV TEST MAIN.vi ‏203 KB

    Since you are acquiring one point at a time, use a shift register and build an array of points , bundle it and display on XY graph
    As shown in attached VI
    Attachments:
    PSV.vi ‏250 KB

  • How to write an array and a scalar to file?

    I would like to write my data to a file but am having trouble approaching the problem. In the file I would like to write both the x and y values of my data points in two columns, however, the y data is in an array and the x data is made up of 3 pieces of information: an initial x, an x incremented value, and the number of points in my data sample. How could I go about this?
    Solved!
    Go to Solution.

    The number of points is redundant, because it will be the same as the "other" array.
    Here's what I usually do:
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ramper.png ‏13 KB

  • Rookie Question: Swap values? Declare an array and values of its indices?

    Hello,
    I hope this is the right forum: I have a simple Java Problem but i do not get it.
    Is like that: I have to swap values within an array e.g i have one array with 3 indices. Indice 0 (the first indice) has value 12. The middle indice has no value, and the second indice has value 9. How to swap 9 to 12 and 12 to 9 without direct swap, in other words, by using the middle indice that has no value or is zero? And how do i write it in an array?
    My other questions: How do i Declare an array and values of its indices?
    I hope this is the right forum or site at all, in cas enot, i hope you still can help or give me links that could help. I really need this.

    Hi Rookie,
         http://forum.sun.com is the best place to get answers for your queries.
         Answer to you first question:
         array[0]=array[0]+array[2]; // array[0] will have 21, because 9+12.
         array[2]=array[0]-array[2]; // array[2] will have 9, because 21-12.
         array[0]=array0]-array[2];  // array[0] will have 12, because 21-9.   
         Hope your first query is resolved.
         I will answer your next query in my next reply.
    Thanks & Regards,
    Charan.  

  • Last One I Promise! Inserting A Value In An Array And Shifting TheRest Over

    Last question I have, I need to know the theory behind inserting a value into an array and shifting the rest over.. I have somewhat of an idea and that is this:
    Obviously I need to use a for loop, and a temp value to hold each value until it shifts then move on to the next value? Oh and increase the size of the array by one? I'm having trouble making sense of it..
    lets say we have the same array as from before
              int[] aRay = new int[5];
              aRay[0] = 1;
              aRay[1] = 9;
              aRay[2] = 3;
              aRay[3] = 4;
    aRay[4] = 11;
    and we want to add... lets say the element 5 into the index spot of 2 is and shift 2 to 3 and 3 to 4 and 4 to 5.
    for ( int i = 0; i < aRay.length; i++) // this will move along each element of the array (so I know I need this for sure)
    Am I on the right track? thanks all
    Edited by: Jojobaba on May 13, 2008 11:50 PM
    Edited by: Jojobaba on May 13, 2008 11:54 PM

    Jojobaba wrote:
    I can do all that, the only trouble I'm having right now is what's the correct way to increase the size of the array by one more? if I try to declare 4 as 5 it gives me a runtime error because 5 is out of bounds, and rightly so, because it doesn't exist
    Once I get that, the rest will be cake
    int[] aRay = new int[5];
    ^
    l
    l
    Do I just make this a 6? or is that not the right way.. :/You can't change array sizes dynamically. You will have to make a new array of the appropriate size and copy into it. You could use copyOf: http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(int[],%20int)
    I hope this is purely an academic exercise, because there's no reason to do this.

  • Calculating min and max value from number array

    I have array which is having return type Number.i want to calculate min and max value of this array..try to help asap..
    Thanks
    dhanu

    hi there,
    public class MinMax {
         int arr[]= { 27, 3, 42, 18, 243, -43, 6, -8 };
         int min, max;
         public MinMax() {
    // it's very bad way to do it.
    //          min=99999;
    //          max=-99999;
    // this must be as following
                    min = max = arr[0];
              search();
              System.out.println("The minimum value is: "+min);
              System.out.println("The maximum value is: "+max);
         private void search() {
    // and here we can search from <1> index instead of <0>
              for (int j=1; j<arr.length; j++) {
                   if (arr[j]<min) {
                        min=arr[j];
                   else if (arr[j]>max) {
                        max=arr[j];
         public static void main(String args[]) {
              new MinMax();
    there is a bug in the supplied code. Your homework is
    to figure out what it is without posting another
    message for help with your homework.well, i think it's a tragedy :(

Maybe you are looking for