Read multiple rows in a single time

Dear All,
Does anyone has idea on how to read using java to read 10000 rows and write it to a file
code:
FileReader fr =
new FileReader(fileDir + "/" + orgFiles);
BufferedReader br = new BufferedReader(fr);
String record = br.readLine();
while (record != null) {
String[] afterSplit = record.split(",");
System.out.println("recordLength : " +afterSplit.length);
for (int p = 0; p < 1; p++) {
test= afterSplit[0];
test1= afterSplit[1];
test1 = afterSplit[2];
it reads a single line in a test file and then write it to another file.i have 100000 rows in that file is there any possibility to read 100000 record in a time (ie) instead of record=br.readline and then split that any other way to read all the rows and assign it to afterSplit ?

Hi kayaman,
Thanks for ur reply.if there are 100000 records in the text file
For Example,
bsc,bsc1,bsc2,bsc3
bsc4,bsc5,bsc6,bsc7
bsc8,bsc9,bsc10,bsc11
it reads bsc,bsc1,bsc2,bsc3 and then write it to some file
is there any possibility to read all
bsc,bsc1,bsc2,bsc3
bsc4,bsc5,bsc6,bsc7
bsc8,bsc9,bsc10,bsc11
then write there thses 3 in a single time.

Similar Messages

  • Read multiple rows to do aggregation

    Hi All
    I need some help here:
    1. I have to read multiple rows to check where time stamp is same for example rownum (1-3) : *'2013/03/09 10:54:09 PM'*
    2. And status is unique for example *(H,L)*
    3. And if TIME_STAMP is between TIME_A and TIME_B then flag it as Y else flag it as N.
    and if the above condition is not true then
    1. Flag the row with ' Y ' where time_stamp is same i.e. : '2013/03/09 10:54:09 PM'
    2. And the status is *( ' O ')*
    3. the other rows where time_stamp is same, and unique_id is same, and STATUS is either or both ( ' H ' , ' L ' ) flag it as *' N '*
    table structure:
    CREATE TABLE T2
      TIME_STAMP  DATE,
      STATUS      VARCHAR2(1 BYTE),
      UNIQUE_ID   NUMBER,
      TIME_A      DATE,
      TIME_B      DATE
    Insert statement;
    SET DEFINE OFF;
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:09', 'MM/DD/YYYY HH24:MI:SS'), 'H', 6587797, TO_DATE('03/09/2013 23:00:22', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:03:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:09', 'MM/DD/YYYY HH24:MI:SS'), 'L', 6587797, TO_DATE('03/09/2013 22:48:35', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:00:22', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:09', 'MM/DD/YYYY HH24:MI:SS'), 'O', 6587797, TO_DATE('03/09/2013 23:03:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:05:54', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:57', 'MM/DD/YYYY HH24:MI:SS'), 'H', 6587797, TO_DATE('03/09/2013 23:00:22', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:03:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:57', 'MM/DD/YYYY HH24:MI:SS'), 'L', 6587797, TO_DATE('03/09/2013 22:48:35', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:00:22', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 22:54:57', 'MM/DD/YYYY HH24:MI:SS'), 'O', 6587797, TO_DATE('03/09/2013 23:03:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 23:05:54', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 18:26:55', 'MM/DD/YYYY HH24:MI:SS'), 'L', 6583483, TO_DATE('03/09/2013 18:15:51', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 18:26:28', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into T2
       (TIME_STAMP, STATUS, UNIQUE_ID, TIME_A, TIME_B)
    Values
       (TO_DATE('03/09/2013 18:26:55', 'MM/DD/YYYY HH24:MI:SS'), 'O', 6583483, TO_DATE('03/09/2013 18:27:01', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/09/2013 18:33:10', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Query used:
    SELECT time_stamp,
           UPPER (SUBSTR(status,1,1)) as status,
           Unique_ID,
           Time_A,
           Time_B,
           CASE
                WHEN time_stamp BETWEEN Time_A AND Time_B
              THEN
                   'Y'
              ELSE
                   'N'
             END   as flag
      FROM t2;
    the query provided above doesn't work with these rows:
    TIME_STAMP,                STATUS,     UNIQUE_ID,      TIME_A,                             TIME_B,                                    FLAG
    2013/03/09 6:26:55 PM,   L,              6583483,          2013/03/09 6:15:51 PM,     2013/03/09 6:26:28 PM,              N
    2013/03/09 6:26:55 PM,   O,              6583483,          2013/03/09 6:27:01 PM,      2013/03/09 6:33:10 PM,             N
    because here where time_stamp is same and time_stamp is not between time_a and time_b therefore it should be flagged Y on the row where status is *' O '*
    Edited by: 855161 on Apr 10, 2013 7:36 AM

    Hi,
    Sorry, it's unclear what you want.
    855161 wrote:
    Hi All
    I need some help here:
    1. I have to read multiple rows to check where time stamp is same for example rownum (1-3) : *'2013/03/09 10:54:09 PM'*
    2. And status is unique for example *(H,L)*
    3. And if TIME_STAMP is between TIME_A and TIME_B then flag it as Y else flag it as N.
    and if the above condition is not true then
    1. Flag the row with ' Y ' where time_stamp is same i.e. : '2013/03/09 10:54:09 PM'
    2. And the status is *( ' O ')*
    3. the other rows where time_stamp is same, and unique_id is same, and STATUS is either or both ( ' H ' , ' L ' ) flag it as *' N '*
    the query provided above doesn't work with these rows:
    TIME_STAMP,                STATUS,     UNIQUE_ID,      TIME_A,                             TIME_B,                                    FLAG
    2013/03/09 6:26:55 PM,   L,              6583483,          2013/03/09 6:15:51 PM,     2013/03/09 6:26:28 PM,              N
    2013/03/09 6:26:55 PM,   O,              6583483,          2013/03/09 6:27:01 PM,      2013/03/09 6:33:10 PM,             Nbecause here where time_stamp is same and time_stamp is not between time_a and time_b therefore it should be flagged Y on the row where status is *' O '*What are the complet, correct results you want from thissample data?
    Are they the same as what you are currently getting, except that the 2 rows above should have flag = 'O'?
    Why should the row that has status='L' get flag='O'?
    Why don't the other rows that currently have status='O' and flag='N' need to be changed?
    To see if there are other rows with the same time_stamp, you can use the analytic COUNT function, like this:
    SELECT time_stamp,
           UPPER (SUBSTR(status,1,1)) as status,
           Unique_ID,
           Time_A,
           Time_B,
           CASE
                WHEN time_stamp BETWEEN Time_A AND Time_B
                    THEN
                        'Y'
                WHEN  COUNT (*) OVER (PARTITION BY  time_stamp) > 1
             AND       UPPER (SUBSTR (status, 1, 1)) = 'O'
                 THEN
                  'O'
                    ELSE
                        'N'
             END   as flag
      FROM t2
    ORDER BY  time_stamp
    ,            status
    ;The results that this produces are :
    `                        UNIQUE
    TIME_STAMP           S      _ID TIME_A               TIME_B               F
    09-Mar-2013 18:26:55 L  6583483 09-Mar-2013 18:15:51 09-Mar-2013 18:26:28 N
    09-Mar-2013 18:26:55 O  6583483 09-Mar-2013 18:27:01 09-Mar-2013 18:33:10 O
    09-Mar-2013 22:54:09 H  6587797 09-Mar-2013 23:00:22 09-Mar-2013 23:03:00 N
    09-Mar-2013 22:54:09 L  6587797 09-Mar-2013 22:48:35 09-Mar-2013 23:00:22 Y
    09-Mar-2013 22:54:09 O  6587797 09-Mar-2013 23:03:00 09-Mar-2013 23:05:54 O
    09-Mar-2013 22:54:57 H  6587797 09-Mar-2013 23:00:22 09-Mar-2013 23:03:00 N
    09-Mar-2013 22:54:57 L  6587797 09-Mar-2013 22:48:35 09-Mar-2013 23:00:22 Y
    09-Mar-2013 22:54:57 O  6587797 09-Mar-2013 23:03:00 09-Mar-2013 23:05:54 OI don't think this is what you wat, but I'm not sure.
    Can you explain, in a different way than before, what flag is supposed to show? What role (if any) does the so-called unique_id play in this problem?

  • How do I insert multiple rows from a single form ...

    How do I insert multiple rows from a single form?
    This form is organised by a table. (just as in an excel format)
    I have 20 items on a form each row item has five field
    +++++++++++ FORM AREA+++++++++++++++++++++++++++++++++++++++++++++++++++++
    +Product| qty In | Qty Out | Balance | Date +
    +------------------------------------------------------------------------+
    +Item1 | textbox1 | textbox2 | textbox3 | date +
    + |value = $qty_in1|value= &qty_out1|value=$balance1|value=$date1 +
    +------------------------------------------------------------------------+
    +Item 2 | textbox1 | textbox2 | textbox4 | date +
    + |value = $qty_in2|value= $qty_out1|value=$balance2|value=$date2 +
    +------------------------------------------------------------------------+
    + Item3 | textbox1 | textbox2 | textbox3 | date +
    +------------------------------------------------------------------------+
    + contd | | | +
    +------------------------------------------------------------------------+
    + item20| | | | +
    +------------------------------------------------------------------------+
    + + + SUBMIT + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Database Structure
    +++++++++++++++++
    + Stock_tabe +
    +---------------+
    + refid +
    +---------------+
    + item +
    +---------------+
    + Qty In +
    +---------------+
    + Qty Out +
    +---------------+
    + Balance +
    +---------------+
    + Date +
    +++++++++++++++++
    Let's say for example user have to the use the form to enter all 10 items or few like 5 on their stock form into 4 different textbox field each lines of your form, however these items go into a "Stock_table" under Single insert transaction query when submit button is pressed.
    Please anyone help me out, on how to get this concept started.

    Hello,
    I have a way to do this, but it would take some hand coding on your part. If you feel comfortable hand writing php code and doing manual database calls, specificaly database INSERT calls you should be fine.
    Create a custom form using the ADDT Custom Form Wizard that has all the rows and fields you need. This may take a bit if you are adding the ability for up to 20 rows, as per your diagram of the form area. The nice thing about using ADDT to create the form is that you can setup the form validation at the same time. Leave the last step in the Custom Form Wizard blank. You can add a custom database call here, but I would leave it blank.
    Next, under ADDT's Forms Server Behaviors, select Custom Trigger. At the Basic tab, you enter your custom php code that will be executed. Here you are going to want to put your code that will check if a value has been entered in the form and then do a database INSERT operation on the Stock_table with that row. The advanced tab lets you set the order of operations and the name of the Custom Trigger. By default, it is set to AFTER. This means that the Custom Trigger will get executed AFTER the form data is processed by the Custom Form Transaction.
    I usually just enter TEST into the "Basic" tab of the Custom Trigger. Then set my order of operations in the "Advanced" tab and close the Custom Trigger. Then I go to the code view for that page in Dreamweaver and find the Custom Trigger function and edit the code manually. It's much easier this way because the Custom Trigger wizard does not show you formatting on the code, and you don't have to keep opening the Wizard to edit and test your code.
    Your going to have to have the Custom Trigger fuction do a test on the submitted form data. If data is present, then INSERT into database. Here's a basic example of what you need to do:
    In your code view, the Custom Trigger will look something like this:
    function Trigger_Custom(&$tNG) {
    if($tNG->getColumnValue("Item_1")) {
    $item1 = $tNG->getColumnValue("Item_1");
    $textbox1_1 = $tNG->getColumnValue("Textbox_1");
    $textbox1_2 = $tNG->getColumnValue("Textbox_2");
    $textbox1_3 = $tNG->getColumnValue("Textbox_3");
    $date1 = $tNG->getColumnValue("Textbox_3");
    $queryAdd = "INSERT INTO Stock_table
    (item, Qty_In, Qty_Out, Balance, Date) VALUES($item1, $textbox1_1, $textbox1_2, $textbox1_3, $date1)"
    $result = mysql_query($queryAdd) or die(mysql_error());
    This code checks to see if the form input field named Item_1 is set. If so, then get the rest of the values for the first item and insert them into the database. You would need to do this for each row in your form. So the if you let the customer add 20 rows, you would need to check 20 times to see if the data is there or write the code so that it stops once it encounters an empty Item field. To exit a Custom Trigger, you can return NULL; and it will jump out of the function. You can also throw custom error message out of triggers, but this post is already way to long to get into that.
    $tNG->getColumnValue("Item_1") is used to retrieve the value that was set by the form input field named Item_1. This field is named by the Custom Form Wizard when you create your form. You can see what all the input filed names are by looking in the code view for something like:
    // Add columns
    $customTransaction->addColumn("Item_1", "STRING_TYPE", "POST", "Item_1");
    There will be one for each field you created with the Custom Form Wizard.
    Unfortunately, I don't have an easy way to do what you need. Maybe there is a way, but since none of the experts have responded, I thought I would point you in a direction. You should read all you can about Custom Triggers in the ADDT documentation/help pdf to give you more detailed information about how Custom Triggers work.
    Hope this helps.
    Shane

  • Select or deselect multiple rows with one single selection  event

    Does anyone know how to create a JTable which can select or deselect multiple rows with one single selection event in JTable. Fore example, if the table has
    row1
    row2
    row3
    row4
    row5
    row6
    What I need is when user select row1 or row2, both row1 and row2 should be set to be selected. Then if user press CTRL and click one of row3 or row4, both of them should be selected including the previouse selected row1 and row2.
    For deselection, if row1 and row2 are selected, when users deselect one of row1 or row2, both of them should be deselected.
    Hopefully someone can give me a hint.

    Here is a partial solution using a JList. Only one line gets highlighted when the user makes a selection in the list. But, two lines are returned. There is a blank line between every two lines.
         private void addLineToList() {
              String a = f_one.getText();
              String b = f_two.getText();
              if (a.length() == 0) {
                   Utils.showInformationMessage("Item field is empty.");
                   f_one.requestFocusInWindow();
                   return;
              if (b.length() == 0) {
                   Utils.showInformationMessage("Match field is empty.");
                   f_two.requestFocusInWindow();
                   return;
              model.addElement("item: " + a);
              model.addElement("match: " + b);
              model.addElement(" ");
              int size = model.getSize();
              pairList.setSelectedIndex(size - 3);
              f_one.setText("");
              f_two.setText("");
              f_one.requestFocusInWindow();
         private void editList() {
              if (pairList.getSelectedValue().toString().equalsIgnoreCase(" ")) {
                   Toolkit.getDefaultToolkit().beep();
                   f_one.requestFocusInWindow();
                   return;
              if (!f_one.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Item field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   OptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              if (!f_two.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Match field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   JOptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              String item = "";
              String match = "";
              int index = pairList.getSelectedIndex();
              String choice = model.getElementAt(index).toString();
              if (choice.startsWith("item")) {
                   item = choice;
                   match = model.getElementAt(index + 1).toString();
                   model.remove(index);
                   model.remove(index);
                   model.remove(index);
              else {
                   item = model.getElementAt(index - 1).toString();
                   match = choice;
                   model.remove(index + 1);
                   model.remove(index);
                   model.remove(index - 1);
              int size = model.getSize();
              if (size > 2) {
                   pairList.setSelectedIndex(size - 2);
              f_one.setText(item.substring(6));
              f_two.setText(match.substring(7));
              f_one.requestFocusInWindow();
         }

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • Multiple rows in a single row.

    I want to know how can I store the values of multiple rowe in a single row.for an example..
    machine name    manchine no  frequency   month
    Lathe                  MOO1          yearly         jan
    Lathe                  MOO1          halfyearly   feb
    Lathe                  MOO1         weekly       march and so on
    I want this in a single row..
    like                        jan       feb             march
    Lathe       M001   yearly     halfyearly   weekly.
    and in a single row I want this as per the month specified .
    In my report I have 12 months distribution for each machine.

    Taruna,
    Just make sure understand the scenario correctly. Would you like to store the row in DB like this:
    Lathe MOO1 yearly jan,feb,mar
    then you expect to show in the report like this:
    Lathe MOO1 yearly jan
    Lathe MOO1 yearly feb
    Lathe MOO1 yearly mar
    Yes, you can do it this way, but somehow break the 1st principle of DB schema design - Atomic
    Of course, you need to convert jan,feb,mar into list and display for each row.
    string monthStr = "jan,feb,mar";
    string [] months = monthStr.Split(",");
    Kind Regards
    -Yatsea

  • 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

  • Multiple row as a single row in a column

    Hi,
    I want to select Multiple rows into a single line in 'Single Column Table' .
    For ex:
    Employee table has only one column , named as empname . it has three rows
    Select empname from emp;
    empname
    thambi
    peter
    antony
    My expected result: thambi,peter,antony

    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002

  • How to insert multiple rows in a single shot using insert command?

    Hi,
    If we insert one row, we can use "insert into" command. I want to insert multiple rows into the table in a single shot. Is there any SQL command for insert multiple rows into the table?
    Plese give the solution.
    Thanks,
    chelladurai

    If you would like to do it with SQL, this would be one of the ways to achive it:
    SQL*Plus: Release 10.2.0.4.0 - Production on Fri Sep 25 10:12:59 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing options
    SQL>
    SQL> desc leap
    Name                                      Null?    Type
    FIRST_PRICE                                        NUMBER(16,6)
    NEXT_PRICE                                         NUMBER(16,6)
    SQL>
    SQL> select * from leap;
    no rows selected
    SQL>
    SQL>
    SQL> !vi multirow_insert.sql
    SQL> !cat multirow_insert.sql
    insert into leap(first_price, next_price) values (1,2);
    insert into leap(first_price, next_price) values (3,4);
    insert into leap(first_price, next_price) values (5,6);
    SQL>
    SQL> @multirow_insert.sql
    1 row created.
    1 row created.
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL>
    SQL> select * from leap;
    FIRST_PRICE NEXT_PRICE
              1          2
              3          4
              5          6
    SQL>

  • Multiple rows Converge to Single row and join

    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    Thank you,
    Aj
    CREATE TABLE DTL_TABLE
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       course   VARCHAR2 (10),
       names    VARCHAR2 (10),
       title    VARCHAR2 (10),
       TYPE     VARCHAR2 (10)
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'jim',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'john',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'kale',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'officer',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'prof',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'inclass');
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'online');
    COMMIT;
    CREATE TABLE id_table
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       loc      VARCHAR2 (10),
       dept     VARCHAR2 (10),
       code     VARCHAR2 (10)
    INSERT INTO id_table
         VALUES ('1',
                 '2010',
                 'nj',
                 '101',
                 'cc');
    COMMIT;

    Aj09 wrote:
    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    SELECT TBL.id,
           DTLperiod,
           course,
           names,
           title,
           TYPE,
           Loc,
           Dept,
           Code
    FROM   ID_TABLE TBL,
           DTL_TABLE DTL
    WHERE  TBL.ID = DTL.ID
           AND TBL.PERIOD = DTL.PERIOD; it not good to use RESERVED WORDS like "ID" or "TYPE" as column names

  • Is there a way in Oracle to return multiple rows as a single string?

    Hi gurus,
    I just got help from your guys fixing my dynamic sql problem. What I am doing in that function is to return a single string from multiple rows and I use it in the select statement. It works fine once the problem was solved. But is there any way in Oracle to do this in the select statement only? I have a table that stores incidents (incident_id is the PK) and another table that stores the people that are involved in an incident.
    Incident_table
    (incident_id number PK);
    Incident_people_table
    (incident_id number PK/FK,
    person_id number PK);
    Now in a report, I need to return the multiple rows of the Incident_People_table as a single string separated by a comma, for example, 'Ben, John, Mark'. I asked the SQL Server DBA about this and he told me he can do that in SQL Server by using a variable in the sql statement and SQL Server will auomatically iterate the rows and concatenate the result (I have not seen his actual work). Is there a similar way in Oracle? I have seen some examples here for some similar requests using the sys_connect_by_path, but I wonder if it is feasible in a report sql that is already rather complex. Or should I just stick to my simpler funcion?
    Thanks.
    Ben

    Hi,
    May be, this example will help you.
    SQL> CREATE TABLE Incident_Table(
      2    incident_id number
      3  );
    Table created.
    SQL> CREATE TABLE Person_Table(
      2    person_id number,
      3    person_name VARCHAR2(200)
      4  );
    Table created.
    SQL> CREATE TABLE Incident_People_Table(
      2    incident_id number,
      3    person_id number
      4  );
    Table created.
    SQL> SELECT * FROM Incident_Table;
    INCIDENT_ID
              1
              2
    SQL> SELECT * FROM Person_Table;
    PERSON_ID PERSON_NAME
             1 John
             2 Mark
             3 Ben
             4 Sam
    SQL> SELECT * FROM Incident_People_Table;
    INCIDENT_ID  PERSON_ID
              1          1
              1          2
              1          3
              2          1
              2          2
              2          4
    6 rows selected.
    SQL> SELECT IT.*,
      2    (
      3      WITH People_Order AS (
      4        SELECT IPT.incident_id, person_id, PT.person_name,
      5          ROW_NUMBER() OVER (PARTITION BY IPT.incident_id ORDER BY PT.person_name) AS Order_Num,
      6          COUNT(*) OVER (PARTITION BY IPT.incident_id) AS incident_people_cnt
      7        FROM Incident_People_Table IPT
      8          JOIN Person_Table PT USING(person_id)
      9      )
    10      SELECT SUBSTR(SYS_CONNECT_BY_PATH(PO.person_name, ', '), 3) AS incident_people_list
    11      FROM (SELECT * FROM People_Order PO WHERE PO.incident_id = IT.incident_id) PO
    12      WHERE PO.incident_people_cnt = LEVEL
    13      START WITH PO.Order_Num = 1
    14      CONNECT BY PRIOR PO.Order_Num = PO.Order_Num - 1
    15    ) AS incident_people_list
    16  FROM Incident_Table IT
    17  ;
    INCIDENT_ID INCIDENT_PEOPLE_LIST
              1 Ben, John, Mark
              2 John, Mark, SamRegards,
    Dima

  • I have a DAQ Assistant configured to read multiple channels at the same time. When I wire a graph indicator to the output, I see all of my signals jumbled together. How do I split them up into seperate signals?

    I have a DAQ Assistant configured to read 2 channels at the same
    time. When I wire a graph indicator to the output, I see the 2
    signals jumbled together. How do I split them up into seperate signals?
    When I wire any type of indicator it is showing just one output of a single channel.
    I want 2 indicators showing 2 different signals as expected from the 2 channels configured. How to do this?
    I have tried using split signal but it end up showing only 1 output from 1 signal in both the indicators.
    thanks in advance.
    Solved!
    Go to Solution.

    Yes you are right. I tried that but I did not get the result.
    I just found the way. When we launch split signal, we should expand it (split signal icon) from above and not from below. It took me a while to figure out this. 
    thanks 

  • Can I have multiple files on a single time capsule?

    On a time capsule, can partition different backups for different files, i.e. different computers.

    As Neil says, you can easily back up multiple Macs to the same Time Capsule, as long as it's large enough (see #1 in the Frequently Asked Questions *User Tip,* also at the top of the +Time Machine+ forum). Each Mac's backups will be in a separate sparse bundle.
    If, as in your other post, any of those other computers are PCs, or even Macs using some other backup app, it gets complicated and messy, because of the way Time Machine backups will use all the space available, and the fact that, as Neil says, you cannot partition the internal HD.
    Your best bet in that case would be to attach a USB hard drive to the Time Capsule; you can partition it if necessary. Back-up one or more Macs to the TC's internal HD or USB drive; and the PC(s) to one or more separate partitions on the USB drive.
    See the Using TIME MACHINE with a TIME CAPSULE *User Tip,* also at the top of this forum.
    As noted in #Q3 there, there is a rather cumbersome way to reserve space on the TC's internal HD for things like the PC backups by putting a +disk image+ on it, but connecting a USB drive will be much easier.

  • Concatenate multiple row values into single column value

    Hello,
    Can anyone please refresh my memory on how to concatenate multiple row values into a single column value.
    In the following query, I will get multiple denial reasons per application and I would rather return all denial reasons on one line.
    SELECT a.application_id, a.membership_number,
    r.reason_text AS denial_reason,
    a.appl_receipt_date AS application_receipt_date,
    a.plan_request_1 AS application_plan_code,
    a.adjudication_date AS application_denial_date
    FROM application a, PLAN p, application_reason ar, reason r
    WHERE a.plan_request_1 = p.plan_cd
    AND a.application_id = ar.application_id
    AND ar.reason_id = r.reason_id
    AND a.adjudication_cd = 'D'
    AND a.appl_receipt_date BETWEEN '01-jan-2006' AND '31-dec-2006'
    AND p.plan_type_id = 12 and a.application_id = :appId
    ORDER BY application_id
    Any help is greatly appreciated.
    Thanks,
    -Christine

    found the following
    SELECT deptno,
           LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
           KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
    FROM   (SELECT deptno,
                   ename,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
            FROM   emp)
    GROUP BY deptno
    CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
    START WITH curr = 1;
        DEPTNO EMPLOYEES
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    3 rows selected.at http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • Oracle query - Merging multiple rows into a single row output

    Hi All,
    I have to have a multiple row output to be converted into a single row output.My current output looks as follows:
    ID YR INC_CODE OFFN SCHOOLNO
    8006 2002 00175 SC03 12
    8006 2002 00175 DC06 12
    8006 2002 00175 DC03 12
    8006 2002 00175 DC02 12
    ID,INCIDENT CODE,OFFENSE are all Primary keys
    So I need the output as follows:(IN ONE ROW)
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 SCHOOLNO
    8006 2002 00175 SC03 DC06 DC03 DC02 12
    Can you help me on this since have been spinning the wheel and this has to be a query since will have couple of tables join to produce a materialized view.
    Thanks in advance

    Hi Nigel,
    Thanks for the reply I tested out the portion having the decode and I get the output as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 -----------------------
    8982 2002 2175 DOC02-------------------
    8982 2002 2175 DOC03------------
    8982 2002 2175 DOC06-------
    8982 2002 2175 SCV03
    There is no value as max for OFFN and each INC_CODE MAY HAVE UP TO A MAX OF 5 OFFN.My query is as follows:
    select distinct STU_STUDENT_ID, INC_BEG_SCH_YR,INC_INCIDENT_CODE
    , decode(rank() over (partition by INC_CODE order by OFFN),1,OFFN,null) as offn1
    , decode(rank() over (partition by INC_CODE order by OFFN),2,OFFN,null) as offn2
    , decode(rank() over (partition by INC_CODE order by OFFN),3,OFFN,null) as offn3
    , decode(rank() over (partition by INC_CODE order by OFFN),4,OFFN,null) as offn4
    , decode(rank() over (partition by INC_CODE order by OFFN),5,OFFN,null) as offn5
    from stu_offn where
    stu_offn.ID = '8982' and stu_offn.INC_CODE = '2175'
    (****Where clause is just given to just check a value)
    So as you know I need to just have all the OFFN in a single row ie as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 DOC02 DOC03 DOC06 SCV03
    Can you just give me a step by step procedure to go through this and the table in this case is just 'STU_OFFN'
    Thanks for the earlier reply appreciate it!
    ****Sending this again to show the exact way the output is coming

Maybe you are looking for

  • How to deploy oracle forms on oracle application server 10g release3

    i have installed oracle database 10.1.0.5 and oracle application server 10.1.3.1. I have to run forms using this setup. I was unable to find which version of oracle application server forms and reports should i install to run. I would appreciate if s

  • Problem Deploying PAR file to EP 6.0 SP2

    I downloaded the latest SAP .Net PDK and I am trying to deploy the PAR file to EP 6.0 (SP2 patch 4 hotfix 5 running on HP11).  The error message that I'm getting isn't telling me a whole lot.  Has anyone else had trouble deploying from a windows syst

  • KamdundefinedError  on all Windows Systems kAMDMessageError

    Hello, i use the newest iphone konfigurationprogramm and i  update my iphones with my own FOVEA app. Since four week it is no more working on all windows PC (XP Win7 Win 8) I have testet on seven Windows PC, i can Install the profile an certifikation

  • Almost too embarrassed to ask

    I just finished reading through the first 14 pages of postings here and I'm more frightened of doing the OS X thing than ever. What are you people talking about? Permissions? Keychains? :<) My work Mac is a blue G3 with OS 9.1, which seems to suit my

  • Convert MathScript node to regular wired diagram

    I wrote a program last year in LabView 8.6, with some MathScript codes in it.  But this year, after I upgraded LabView to 2009 Full Development System, I am not able to run this program anymore because I didn't purchase the MathScript Module.  And wh