Multiple counts in a single statement

Hi,
I am trying to get a total count of the number of employees in departments as well as the total numbers in specific salary ranges and display it all in one set of results.
Here is the code I have so far:
select distinct e.department_id,
ct1.subct+ct2.subct+ct3.subct+ct4.subct total_num,
ct1.subct,
ct2.subct,
ct3.subct,
ct4.subct
from employee e,
(select department_id, count(department_id) subct from employee where salary < 1500 group by department_id) ct1,
(select department_id, count(department_id) subct from employee where salary >= 1500 and salary <=2499 group by department_id) ct2,
(select department_id, count(department_id) subct from employee where salary >= 2500 and salary <=3499 group by department_id) ct3,
(select department_id, count(department_id) subct from employee where salary >= 3500 group by department_id) ct4
where e.department_id=ct1.department_id
and e.department_id=ct2.department_id
and e.department_id=ct3.department_id
and e.department_id=ct4.department_id
The problem with this code is that it only displays departments which have at least one employee in each of the salary ranges in the results. This is because of the join statements, I know, but is there any way around it?
I know there are some alternative approaches altogether to this problem, using the likes of ROLLUP and so on, but I would like to do it using essentially a similar method to my code above, if that is in fact possible.
Any assistance would be appreciated!

Can yu use ROLLUP..?
SQL> select d.deptno,case when sal < 1500 then 'Low'
  2                       when sal between 1500 and 3000 then 'Medium'
  3                       when sal is null then 'No emp'
  4                       else 'High'
  5                   end sal_range,count(empno)
  6  from dept d,emp e
  7  where d.deptno = e.deptno(+)
  8  group by rollup(d.deptno,case when sal < 1500 then 'Low'
  9                       when sal between 1500 and 3000 then 'Medium'
10                       when sal is null then 'No emp'
11                       else 'High'
12                   end);
    DEPTNO SAL_RA COUNT(EMPNO)
        10 Low               1
        10 High              1
        10 Medium            2
        10                   4
        20 Low               2
        20 Medium            3
        20                   5
        30 Low               3
        30 Medium            3
        30                   6
        40 No emp            0
    DEPTNO SAL_RA COUNT(EMPNO)
        40                   0
        45 No emp            0
        45                   0
                            15
15 rows selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Can I combine multiple entries into a single statement?

    I am relatively new to Live Cycle so forgive my lack of technical wording.
    I would like to use multiple entry fields to fill in a statement.
    For example:
    I'd like the user to see this:
    Target Dropdown     Endo Dropdown     Type Dropdown     Version # Entry     Date 1 Entry     Date 2 Entry
    and then have the form merge all that together into a line that looks like this:
    RS_(target)_(endo)_(type)\(version)_(date)_(date)
    Preferably without repeating information on the page as we'll have multiple of these entries and the page will get hectic quick.
    Is this possible?
    I first had each dropdown in individual table fields, but due to regulations we follow the entries need to be merged without spaces.
    I always have a backup if this can't be done, but any help is appreciated.

    Not sure where you're sending it, but if you have a global variable named "bob".
    bob.value = "RS_"+target.rawValue+"_"+endo.rawValue+"_"+type.rawValue+"\"+version.rawValue+"_"+date.r awValue+"_"+date2.rawValue;
    Something like that should work.

  • Inserting multiple rows using a single Insert statement without using dual

    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;

    NiranjanSe wrote:
    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;
    SQL> create table ps_hd_samp (num1 number,num2 number);
    Table created.
    SQL> insert all
      2  into ps_hd_samp (num1,num2) values (1,1)
      3  into ps_hd_samp (num1,num2) values (2,2)
      4  into ps_hd_samp (num1,num2) values (3,3)
      5  select count(*)
      6  from ps_hd_samp;
    3 rows created.
    SQL> select * from ps_hd_samp;
          NUM1       NUM2
             1          1
             2          2
             3          3

  • Merge statement - update multiple columns from a single sub-select

    Is it possible to write in 10gR2, a MERGE statement, with UPDATE for multiple columns from a single sub_select?
    like this:
    MERGE INTO tableA
    using ( select * from temp) tmp
    on( tableA. col1 = tmp.col1)
    when matched then
    update set  ( tableA.col5,
                       tableA.col6,
                       tableA.col7) = ( select sum(col2), sum(col3), sum(col5)
                                                                                 from tableX
                                                                                where tableX.col1 = tableA.col1...)

    Hi,
    The USING clause is not a sub-query, so it can't reference columns from tables that are not in it.
    Include tableA in the USING clause if you really need to refer to it there. (It's not obvious that you do.)
    As always, it helps if you post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (In the case of a DML statement, such as MERGE, this will be the state of the tables when everything is finished.)
    (4) Your best attempt so far (formatted)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3).

  • Update multiple rows & columns using a single statement

    I have the following table with tablename - emp
    first_name last_name age
    aaa bbb 31
    56
    78
    ggg hhh 36
    2nd & 3rd row contain null values (no data) in first_name & last_name column . I want to update those two rows with data using a single statement. How do I do it?
    I was thinking may be something like the following:-
    UPDATE emp
    SET first_name= , last_name=
    CASE
    WHEN age = 56 THEN 'ccc', 'ddd'
    WHEN age = 78 THEN 'eee', 'fff'
    ELSE first_name, last_name
    END
    -----------------------------------------------

    Can you give an example of a nested decode statement.
    test@ora>
    test@ora>
    test@ora> --
    test@ora> drop table t;
    Table dropped.
    test@ora> create table t as
      2  select rownum x, cast(null as varchar2(10)) y from all_objects
      3  where rownum <= 10;
    Table created.
    test@ora>
    test@ora> select x, y from t;
             X Y
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    test@ora>
    test@ora> -- You want to change the values of y to 'a' through 'j' for x = 1 through 10
    test@ora> -- and y = 'X' otherwise
    test@ora> --
    test@ora> -- Let's say the limit on the number of components were 12
    test@ora> -- Then your decode statement would've been:
    test@ora> --
    test@ora> update t
      2  set y = decode(x,
      3                 1, 'a',
      4                 2, 'b',
      5                 3, 'c',
      6                 4, 'd',
      7                 5, 'e',
      8                    'f');
    10 rows updated.
    test@ora>
    test@ora>
    test@ora> select x, y from t;
             X Y
             1 a
             2 b
             3 c
             4 d
             5 e
             6 f
             7 f
             8 f
             9 f
            10 f
    10 rows selected.
    test@ora>
    test@ora> -- As you can see you are unable to:
    test@ora> --
    test@ora> -- change y to 'g' if x = 7
    test@ora> -- change y to 'h' if x = 8
    test@ora> -- change y to 'i' if x = 9
    test@ora> -- change y to 'j' if x = 10
    test@ora> -- change y to 'X' otherwise
    test@ora> --
    test@ora>
    test@ora> -- What you would do then is -
    test@ora> -- (i)  Let the 11 components remain as they are and
    test@ora> -- (ii) Introduce a nested decode function *AS THE 12TH COMPONENT*
    test@ora> --
    test@ora>
    test@ora> rollback;
    Rollback complete.
    test@ora>
    test@ora> --
    test@ora> update t
      2  set y = decode(x,
      3                 1, 'a',
      4                 2, 'b',
      5                 3, 'c',
      6                 4, 'd',
      7                 5, 'e',
      8                 decode(x,
      9                        6,  'f',
    10                        7,  'g',
    11                        8,  'h',
    12                        9,  'i',
    13                        10, 'j',
    14                            'X')
    15                );
    10 rows updated.
    test@ora>
    test@ora> select x, y from t;
             X Y
             1 a
             2 b
             3 c
             4 d
             5 e
             6 f
             7 g
             8 h
             9 i
            10 j
    10 rows selected.
    test@ora>
    test@ora>HTH
    isotope
    Extrapolate that to 255 components and you get 254 + 255 = 509 components. And so on...
    Message was edited by:
    isotope

  • Query to display multiple counts in the result

    Hi,
    I need to be able to display multiple counts for different items in the single result set:
    Here is the simplified schema:
    I have 2 tables:
    STATEMENT table:
    ===============
    statement_pk number,
    department varchar2(20)
    STATEMENT_INFO table:
    ===================
    statement_info_pk number,
    statement_fk number
    is_statement_done varchar2(1)
    is_statement_locked varchar2(1)
    I need to display counts of how many records where done and how records where locked in the
    single output:
    Statement_PK Department NumberOfStatementsDone# NumberofStatementsLocked#
    1          ABC_dept          3                    5
    2          DEF_dept          4                    8
    3          XYZ_dept          7                    2
    The following does not work:
    SELECT
    s.statement_pk,
    s.department,
    COUNT(r.statement_info_pk ) NumberOfStatementsDone# ,
    COUNT(rr.statement_info_pk ) NumberOfStatementsLocked#
    FROM STATEMENT s ,
    STATEMENT_INFO r,
    STATEMENT_INFO rr
    WHERE
         s.statement_pk = r.statement_fk
         AND     s.statement_pk = rr.statement_fk
         AND      is_statement_done = 'Y'      AND rr.is_statement_locked = 'Y'
    GROUP BY statement_pk, s.department
    I was trying to work with analytic function but could not figured it out either.
    Please help
    Thanks,
    Ia.

    this would be something like:
    SQL> r
      1  select statement_pk,
      2         department,
      3         sum(decode(is_statement_done, 'Y', 1, 0)) statement_done,
      4         sum(decode(is_statement_locked, 'Y', 1, 0)) statement_locked
      5  from   statement_info,
      6         statement
      7  where  statement_fk = statement_pk
      8* group by statement_pk, department
    STATEMENT_PK DEPARTMENT           STATEMENT_DONE STATEMENT_LOCKED
               1 ABC_dept                          4                1
               2 DEF_dept                          6                2
               3 XYZ_dept                          1                2
    SQL> Message was edited by:
    Leo Mannhart
    Craig you were faster

  • Multiple selects() within a single VM

    Is anyone aware of any contention issues when running multiple threads within a VM where each thread has it's own select statement?
    I have an home grown app server that allows me to run multiple applications within a single VM. The applications are unrelated however they sometimes communicate with each other via TCP. All of them are very network intensive ( 500 messages a second where each message is around 200 bytes ). These apps are usually single threaded where the main thread is a select() loop.
    Therefore, each application is a single threaded select() loop but there are multiple applications running within a single VM.
    I am seeing performance issues when two apps running within the same VM try to send messages to one another via TCP. When the two apps are running on different boxes one app can send about 10,000 messages a second to the other app. However, when the apps are running within the same VM ( localhost TCP connection ) I can only transfer about 1000 messages a second.
    Are 2 selectors running within the same VM a problem? Is it synchronized within the VM so that only one select can fire at a time?
    I am running on a dual proc RH3 box with plenty of memory.
    Any ideas?

    Works for me, though I'm trying on Windows. Test program below. I get >10,000 replies and responses per second over loopback with both "java SelectPingPong both" (one VM) and running client and server on separate VMs.
    Does this program get only 1000 messages/s on Linux? What VM version?
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class SelectPingPong
        private static final int MESSAGE_SIZE = 200;
        private String server_name;
        private Selector selector;
        private HashMap clients = new HashMap();
        static class Client
         ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
         long connect_time = System.currentTimeMillis();
         int number_of_messages;
        public SelectPingPong(int port, String server_name)
         throws IOException
         this.server_name = server_name;
         selector = Selector.open();
         ServerSocketChannel server_channel = ServerSocketChannel.open();
         server_channel.configureBlocking(false);
         server_channel.socket().bind(new InetSocketAddress(port));
         server_channel.register(selector, SelectionKey.OP_ACCEPT);
        public Socket connect(String host, int port)
         throws IOException
         SocketChannel channel = SocketChannel.open();
         Socket socket = channel.socket();
         socket.connect(new InetSocketAddress(host, port));
         configureSocket(socket);
         channel.configureBlocking(false);
         channel.register(selector, SelectionKey.OP_READ);
         clients.put(channel, new Client());
         return socket;
        private void configureSocket(Socket socket)
         throws IOException
         // Let's say we have a request-reply protocol with modest requirements
         socket.setReceiveBufferSize(1024);
         socket.setSendBufferSize(1024);
        public void mainLoop()
         while (true) {
             try {
              selector.select();
              for (Iterator iter = selector.selectedKeys().iterator(); iter.hasNext(); ) {
                  SelectionKey key = (SelectionKey) iter.next();
                  iter.remove();
                  if (!key.isValid())
                   continue;
                  if (key.isAcceptable())
                   acceptClient(key);
                  if (key.isReadable())
                   readFromClient(key);
             } catch (Exception e) {
              System.out.println(server_name + ": error in selector loop: " + e);
              e.printStackTrace();
        private void acceptClient(SelectionKey key)
         throws IOException
         ServerSocketChannel server_channel = (ServerSocketChannel) key.channel();
         if (server_channel == null)
             return;
         SocketChannel channel = server_channel.accept();
         if (channel == null)
             return;
         configureSocket(channel.socket());
         channel.configureBlocking(false);
         channel.register(selector, SelectionKey.OP_READ);
         clients.put(channel, new Client());
         System.out.println(server_name + ": got a new client; " +
                      clients.size() + " clients");
        private void readFromClient(SelectionKey key)
         throws IOException
         SocketChannel channel = (SocketChannel) key.channel();
         Client client = (Client) clients.get(channel);
         ByteBuffer buf = client.buf;
         int count;
         try {
             count = channel.read(buf);
         } catch (IOException e) {
             System.out.println(server_name + ": error reading, closing connection: " + e);
             clients.remove(channel);
             channel.close();
             return;
         if (count == -1) {
             clients.remove(channel);
             System.out.println(server_name + ": client disconnected; " +
                          clients.size() + " clients");
             channel.close();
             return;
         if (buf.position() == MESSAGE_SIZE) {
             if (++client.number_of_messages % 10000 == 0) {
              long now = System.currentTimeMillis();
              System.out.println(server_name + ": " + client.number_of_messages +
                           " messages in " + (now - client.connect_time) + " ms");
             buf.flip();
             // RFE write without blocking
             writeFully(channel, buf);
             buf.rewind();
        public static void writeFully(SocketChannel channel, ByteBuffer buf)
         throws IOException
         while (buf.remaining() != 0)
             channel.write(buf);
        private static void startClient()
         throws Exception
         SelectPingPong client = new SelectPingPong(6667, "client");
         Socket socket = client.connect("localhost", 6666);
         // Send initial message
         ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
         buf.put(new byte[MESSAGE_SIZE]);
         buf.flip();
         socket.getChannel().write(buf);
         client.mainLoop();
        public static void main(String args[])
         throws Exception
         if (args.length == 1 && args[0].equals("server")) {
             SelectPingPong server = new SelectPingPong(6666, "server");
             server.mainLoop();
         } else if (args.length == 1 && args[0].equals("client")) {
             startClient();
         } else if (args.length == 1 && args[0].equals("both")) {
             new Thread() { public void run() {
              try {
                  SelectPingPong server = new SelectPingPong(6666, "server");
                  server.mainLoop();
              } catch (Exception e) {
                  System.err.println("error in server");
             } }.start();
             startClient();
         } else {
             System.err.println("usage: SelectPingPong [client | server | both]");
    }

  • Selecting data from Multiple Partitions in a single select stmt.

    Hi all,
    My Database is very large & my tables are partitioned.
    My question is:
    1) If my data is spread across multiple partitions, is there any way to select data from multiple partitions in a single query?
    If we dont mention partition name also it works fine, but perofmance wise it will be very slow. (Using EXPLAIN PLAN)
    (Note:I dont want to make use of Union concept, i want to do it in a single select statement)
    For ex:
    qry1.sql:
    select empno from emp_trans partition (P012000)
    This above query(qry1.sql) will work fine.
    qry2.sql:
    select empno from emp_trans partition (P012000,P022000)
    The above query(qry2.sql) will return will return the following error:
    ORA-00933: SQL command not properly ended
    If anybody has any solution for this, pls mail me immediately.
    Thanks in advance
    bye
    null

    All my queries are dynamically generated. All my tables are also indexed partition wise based on date field. My question is, if i want to mention multiple partition names at the time of generating my query(select), then with parformance will be good. I have refered some books, inthat what they say is to use UNION concept, i dont want to use that, instead i want in a single select statement.
    Thaks for ur reply
    Bye
    null

  • With multiple events in a single event case, how to associate value with the correct object?

    I am playing with the template where an event structure takes note of user inputs and a main state machine is then used to respond to these inputs. When I only monitor one control I use the 'NewVal' output to read out the changed value. But when I monitor multiple objects with a single case I also have to associate the readout with the correct owner. After some tinkering I was able to extract the label property and use a case to assign them. Are there better ways of doing this? For example maybe there is a way to connect the label text directly to the 'bundle by name'?
    Also this should be easy to accomplish by simply creating local variables of the objects and read from them, but I got the impression that the use of global and local variables is now strongly discouraged?
    Thanks for any suggestions!
    Attachments:
    Untitled.png ‏39 KB

    Well, I don't really like these theroretical discussions. Can you attach a simplified version of some of your code?
    There are many other ways to identify the particular control. You could for example search an array of references for the value of the "ctlref" event data node. This would make the code much more robust (your code will fail for example if you (or some other programmer updating your code in a few years!) notices a mispelling and edits the label without also changing the case structure cases).
    LabVIEW Champion . Do more with less code and in less time .

  • Is there any way to create multiple users in a single shot in oracle db

    Can Any one tell me, is there any way to create multiple users in a single shot in oracle database.

    Hello Nunhum,
    I guess this was not my question.. This is not what I m asking.. I know there is not a single sql statement in oracle ,which could create multiusers alike UNIX/LINUX(OS LEVEL), Whatever you have written..is simple creating them one by one.
    What I am expecting is to have PL/SQL statement which could help us in this regard.

  • Combine select and update into single statement,without bind-variable

    I have a problem, that I think is not possible to solve the way I want to, but I just wanted to check before leaving the idea...
    I am looking for a way to combine the select and the update statement into one single statement. This is what I wan't to achive: select some data, and update the data selected before returning them.
    On this site http://www.psoug.org/reference/update.html I see that the following are possible:
    var bnd1 NUMBER
    var bnd2 VARCHAR2(30)
    var bnd3 NUMBER
    UPDATE employees
    SET job_id ='SA_MAN', salary = salary + 1000,
    department_id = 140
    WHERE last_name = 'Jones'
    RETURNING salary*0.25, last_name, department_id
    INTO :bnd1, :bnd2, :bnd3;
    I need to have this as a single statement, and cannot use bind-variables. So I was hoping that something like this could be possible:
    UPDATE customer c
    SET c.HAS_CREDIT ='1'
    WHERE c.HAS_CREDIT = '0'
    RETURNING c.CUSTOMER_NO, c.FIRSTNAME, c.LASTNAME
    where c.HAS_CREDIT = '1'
    But this doesn't compile, complaining of missing into (ORA-00925: missing INTO keyword). And even though I would like this to be possible because this would solve my current problem, I think it would be very confusing. For instance; would the where clause of the returning part be operating after the update or before?
    Any comments or suggestions on how to get it work in a single statement, or should I just leave this path straight away?

    Hi,
    RETURNING only works with bind variables, see
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm#sthref3006
    The real problem is that the form of RETURNING clause with bind variables is only valid for single row update or insert statements.
    To update (or insert) multiple rows and return the data, you will need to use
    RETURNING BULK COLLECT INTO clause. See
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2236
    Cheers,
    Colin

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • Multiple records as a single transaction in JDBC Receiver Adapter

    Hi,
    I am sending multiple records in a single message to a JDBC receiver adapter to get updated to the database. How to make all the insert a single transaction. Like all the records has to be inserted else all has to be rolled back.
    For eg for table Employee two fields EMPNO and EMPNAME
    EMPNO  EMPNAME
    1            Jay
    2            Christie
    These two records are in the same message and has to be updated
    if one fails the other has to be rolled back.
    How can i achieve it using a JDBC Receiver Adapter.
    Thanks
    Sebin

    Hi Rolf Micus,
    My xml structure to insert 2 tables are as follow:-
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_PODB xmlns:ns0="http://abeam.com/xi/fer_filejdbc_scenarios1">
    ..   <STATEMENT_HEADER>
    ....      <ROW action="INSERT">
    ......         <TABLE>ZPO_HEADER</TABLE>
    ......        <access>
    ........            <PONUMBER>001</PONUMBER>
    ........            <PODATE>20070801</PODATE>
    ........            <POAMOUNT>200.99</POAMOUNT>
    ....         </access>
    ....      </ROW>
    ..   </STATEMENT_HEADER>
    ..   <STATEMENT_DETAIL>
    ....      <ROW action="INSERT">
    ......         <TABLE>ZPODETAIL</TABLE>
    ......         <access>
    ........            <PONUMBER>001</PONUMBER>
    ........            <PONO>1</PONO>
    ........            <POITEMCODE>A12345</POITEMCODE>
    ........            <POITEMDESC>Testing A</POITEMDESC>
    ........            <POITEMAMOUNT>2990.00</POITEMAMOUNT>
    ........            <POITEMQTY>55</POITEMQTY>
    ......         </access>
    ....      </ROW>
    ..   </STATEMENT_DETAIL>
    </ns0:MT_PODB>
    Fro the structure that you have declared..there is only contained 1 statement, try to admend your MT to have 2 statements.
    If you wish to insert multiple records, just create a loop/multiple of access tag inside STATEMENT tag. For example, multiple records insert into Header should have multiple access tag in Header STATEMENT. Same goes for muliple records insert into Details STATEMENT should have multiple access tag in Details STATEMENT.
    With this structure, whenever any records insert/update/delete failed...it will rollback all the transactions together, ie. Header and Details.
    PS: For different table, please create different STATEMENT.
    Hope it helps.
    Message was edited by: Pua Ming Fei

  • Adding count from two select statements

    Hi,
    How to add counts from two select statements in a single SQL statement.
    For ex: I have
    SELECT COUNT(DISTINCT COL1) FROM table1
    and
    SELECT COUNT(DISTINCT COL2) FROM table2.
    I want to add the counts from these two sqls in a single select query. How to do this.
    Thanks & Regards,
    Sunil.

    select ((SELECT COUNT(DISTINCT COL1) FROM table1) + (SELECT COUNT(DISTINCT COL2) FROM table2)) as "total" from dual;
    regards,

  • The best way to do paging and get total rows count given a sql statement

    Hi,
    Just got a quick question.... what is the best way to do paging as well as the total rows count given by a sql statement.
    e.g. "select * from emp"
    1. I need to know the total row count for this statement.
    2. I also need to do a 10 rows per page....
    Is there a way to do it in a SINGLE statement for best performance?
    Thanks experts.

    Sounds more like a "formatting" problem...
    If Sql*plus is your reporting tool, check out the guide:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/toc.htm

Maybe you are looking for

  • Media controls keys does not work on iTunes?

    My keyboard has those "Media Controls Keys" on it (just like Play or Stop etc.) but it won't work with iTunes, unless iTunes is on the front of all windows. I used to use Windows Media Player and it can work with the Media Controls Keys even the play

  • Best way to store data obtained from a resultset !?

    Hi all, I am working on a verification process that is to be run on our DB upon every external db extraction prior to merge into our DB (which is being done manually now) What I have decided so far is to have a verifier interface that is implemented

  • Users And Security Best Practice

    Dear Experts I am designing an application with almost fifty users scattered in different places. Each users should access tables according to his/her criteria. For example salessam, salesjug can see only the sales related tables. purchasedon should

  • External document (URL) don't save the link

    Hi experts, I want to show "Service for object" button by creating Business Object (SWO1) with Interface = IFGOSXSERV Keyfield = Ref. Table --> ANLA                  Ref. field --> ANLN1 And my codes : CONSTANTS: OBJTYPE TYPE BORIDENT-OBJTYPE VALUE '

  • Nombre d'entrées "MS Office Report Express"

    Bonjour à tous, Je dois générer un rapport d'essai sous Word comprenant des chaînes de caractère et des valeurs de pression, température, vitesse moteur .. etc. Je dois écrire environ 70 données dans le même fichier *.dot Seulement le VI Express "MS