How do I insert or update multiple values in a field of diff files

Hai All

I need to insert or update or multiple values in a single diff of one field records to another table.


Table 1 has 3 fields

Bartime bardate barcode

02/01/10 0011, 0815

02/01/10 0022, 0820

02/01/10 0011, 1130

02/01/10 0022, 1145

02/01/10 0011, 1230

02/01/10 0022, 1235

02/01/10 0011, 1645

02/01/10 0022, 1650


These are the times that arrives at 0815 and pauses at 1130 and arrives at 12: 30 a.m. and coming home at 4:45 pm
These table I have to insert into another table called table2
and the fields are bar codes, date, intrinsically timein, introut, tiomout

And the output you want to like this

barcode timein intrinsically introut timeout date
0011 0815 1130 1230 1645 02/01/10

0022 0820 1145 1235 1650 02/01/10

If all give some good answer that it will be help full...

Thanks and greetings

Srikkanth.M

Try like this

with t
as
(
select '0011' barcode,to_date('01-02-10','dd-mm-yy') bardate,'0815' bartime from dual union all
select '0022',to_date('01-02-10','dd-mm-yy'),'0820' from dual union all
select '0011',to_date('01-02-10','dd-mm-yy'),'1130' from dual union all
select '0022',to_date('01-02-10','dd-mm-yy'),'1145' from dual union all
select '0011',to_date('01-02-10','dd-mm-yy'),'1230' from dual union all
select '0022',to_date('01-02-10','dd-mm-yy'),'1235' from dual union all
select '0011',to_date('01-02-10','dd-mm-yy'),'1645' from dual union all
select '0022',to_date('01-02-10','dd-mm-yy'),'1650' from dual
)
select barcode,
       bardate,
       max(decode(rno, 1, bartime)) timein,
       max(decode(rno, 2, bartime)) interin,
       max(decode(rno, 3, bartime)) interout,
       max(decode(rno, 4, bartime)) timeout
  from (select barcode,
               bardate,
               bartime,
               row_number() over(partition by barcode, bardate order by to_date(bartime,'hh24:mi')) rno
          from t)
 group by barcode, bardate

Tags: Database

Similar Questions

  • How to write insert and update blocks about with an if

    Hai All

    How to write an insert and update block education about with in an if

    I had a condition Ie

    If the time is between 0630 and 1030


    then

    Insert into Daily_attend
    ----


    Update Daily_attend set

    -----

    Concerning

    Srikkanth.M

    There is nothing preventing you to do this:

    BEGIN
      INSERT INTO x (mycolumn) VALUES ('A');
    
      UPDATE x
      SET mycolumn = 'B'
      WHERE mycolumn = 'A';
    
      COMMIT;
    END;
    /
    

    other than the fact that he seems a bit inefficient. Yet once you try to do, and why, is not clear.

    Can you put an IF statement in there to choose one way or the other under certain conditions? Yes. But I wonder if what you
    are actually trying to do is to reinvent the MERGE statement.
    http://www.morganslibrary.org/reference/merge.html

  • How ins or upd multiple values in a record of diff of the fields by using the cursor

    Hai All

    I need to insert or update or multiple values in a single diff of one field records to another table.

    Table 1 has 3 fields

    Bartime bardate barcode

    02/01/10 0011, 0815

    02/01/10 0022, 0820

    02/01/10 0011, 1130

    02/01/10 0022, 1145

    02/01/10 0011, 1230

    02/01/10 0022, 1235

    02/01/10 0011, 1645

    02/01/10 0022, 1650


    These are the times that arrives at 0815 and pauses at 1130 and arrives at 12: 30 a.m. and coming home at 4:45 pm
    These table I have to insert into another table called table2
    and the fields are bar codes, date, intrinsically timein, introut, tiomout

    And the output you want to like this

    barcode timein intrinsically introut timeout date
    0011 0815 1130 1230 1645 02/01/10

    0022 0820 1145 1235 1650 02/01/10

    If all give some good answer that it will be help full...

    Thanks and greetings

    Srikkanth.M

    Hi Srikanth,

    1. first create a datablock (better do instead of the table because its only for querying details of table 1 for the period) with table1 as table base and better use order by clause in form as "order to barcode, date, bartime.

    2. create a second datablock with table2 and get this rank on the two table (second block as base table, because here, you should insert/update)

    now on the screen you can see all the data in 2 tables.

    3. fix the button of some process.

    a time-but-press

    Loop

    1 block of travel and take a line

    Find the same block 2

    If code in bars-avail so
    -you want to update
    on the other
    -you want to insert

    end if;

    end of loop

    and 2nd block will be updated / inserted as u desire, and finally, you can save the second block.

    Iqbal

  • How to choose Insert or update action in bean managed

    Hello

    uses: Studio Edition Version 11.1.1.6.0, JDEVADF_11.1.1.6.0_GENERIC_111205.1733.6192.1 building

    I have a .jspx page that shows a table of the table db (table 1). On the page, the user can modify the data and commit the changes to db by clicking a command button. Command button triggers a java method, inside java tries to get the only edited lines and insert new db table (table 2). Use entity of table2 object for insertion in table2. I can able to insert these steps correctly.

    Again once when the user changes the same line, which was just inserted in table2, I want to update the same row in the table2 recently inserted.

    Insert for the first time is easy, but how to choose Insert (if it is new to table2) or update (if it already exists in table2) in consecutive calls.

    Concerning

    Siva

    You can try to look for the line of table2 by using the method findByKey() of the ViewObject.

    If findByKey() returns 1 row, this means that you need to update.

    If it returns 0 rows means that you need to insert a new line.

    Kind regards

    Elias.

  • How can I insert an infinity symbol or resistance by labview in excel file

    Hello. I need insert infinite synbol in report excel file. How can I make that easly, maybe you have a ready function for this target.

    If you don't want to get into the EXCEL class & its node propert, average the simplest is to SAVE the macro to insert EXCEL result.

    The copy of the generated VB code & use it in LABVIEW using EXCEL MACRO screws.

  • Concatenate - how to get rid of "null null" values defult in field.

    I have concatenated with success the first and last name fields in the design of the form, but when I open/run form the concatenated field (FullName) by default is "null null" on the Form Design.png form. I want it to be empty, until the user enters data into the fields FirstName and LastName.

    I'm not an experienced Java script engine and need to have the full script, exactly as it should be entered from end to end.

    Here's what's in the current script script editor:

    Form1. Subform1.FullName::calculate - (JavaScript, client)

    var = form1 first. Subform1.FirstName.RawValue;

    var last = form1. Subform1.LastName.RawValue;

    this.rawValue = first + "" + last;

    LiveCycle Designer ES2

    Windows 8

    Post edited by: PenEliz1, I have added a screenshot.

    You just need to do a check of the Null value.

    var = form1 first. Subform1.FirstName.RawValue;

    var last = form1. Subform1.LastName.RawValue;

    If (first! = null & last! = null) {}

    this.rawValue = first + "" + last;

    }

    Sofiane

  • Multiple values in a field

    Hello
    I have this problem:
    -In a field in a table, I many values float (in number) instead of a char value (for example: ' a; b; c; e; h; is rather than 'a').
    -This field contains all of the values separated by a '; '.
    -I have to use this field as a variable to a procedure that must use these values in the query filter.

    My question is: there is a way easy to extrapolate all the submitted values and put them in the query filter (I mean dynamically because I don't know if there are values of 3, 6, 1, or 0!).

    Is this my question clear?
    My DB version is 10.2.

    Steven

    Hello

    HM wrote:
    When the other table contains codes that a single letter, you could use something like this:

    select * from yourmulticode_table m,
    yoursinglecode_table s
    where m.multicode like '%'||s.singlecode||'%';
    

    If the elements can contain more than 1 character, the equivalent is

    WHERE    ';' || m.multicode  || ';'     LIKE
         '%;' || s.singlecode || ';%'
    
  • Enter multiple values in a field

    I want to get after two rows in a file.
    Thank you in advance!

    ID name category
    John 109 C1
    John 109 D8

    Result:
    ID name category
    John 109 C1, D8

    Hi, I used centinul East of suggestion to create this query.

    WITH tablet AS
         (SELECT '109' AS ID, 'John' AS NAME, 'C1' AS CATEGORY
            FROM DUAL
          UNION ALL
          SELECT '109' AS ID, 'John' AS NAME, 'D8' AS CATEGORY
            FROM DUAL)
    SELECT     ID, NAME,
               LTRIM
                  (MAX (SYS_CONNECT_BY_PATH (CATEGORY, ','))KEEP (DENSE_RANK LAST ORDER BY ID),
                   ','
                  ) AS CATEGORY
          FROM (SELECT ID, NAME, CATEGORY,
                       ROW_NUMBER () OVER (PARTITION BY ID ORDER BY CATEGORY)
                                                                          AS curr,
                         ROW_NUMBER () OVER (PARTITION BY ID ORDER BY CATEGORY)
                       - 1 AS prev
                  FROM tablet)
      GROUP BY ID, NAME
    CONNECT BY prev = PRIOR curr AND ID = PRIOR ID
    START WITH curr = 1;
    

    or

    WITH tablet AS
         (SELECT '109' AS ID, 'John' AS NAME, 'C1' AS CATEGORY
            FROM DUAL
          UNION ALL
          SELECT '109' AS ID, 'John' AS NAME, 'D8' AS CATEGORY
            FROM DUAL)
    SELECT     ID, NAME, SUBSTR (SYS_CONNECT_BY_PATH (CATEGORY, ','),
                                 2)CATEGORY
          FROM (SELECT ID, NAME, CATEGORY, COUNT (*) OVER (PARTITION BY ID) cnt,
                       ROW_NUMBER () OVER (PARTITION BY ID ORDER BY CATEGORY) seq
                  FROM tablet)
         WHERE seq = cnt
    START WITH seq = 1
    CONNECT BY PRIOR seq + 1 = seq AND PRIOR ID = ID;
    

    Published by: DeepakDevarapalli on November 12, 2009 14:45

    Published by: DeepakDevarapalli on November 12, 2009 14:46

  • How to pass multiple values of payload through the contextual event - jdev 11.1.2.3

    Hello:

    How to configure contextual events publish several values of payload?

    On click of a button, I'm declaritively publish a contextual event, which works very well when a single value is passed to the event handler.

    My event handler method has the signature of:
    eventHandler (String)

    But now I also have an oracle.jbo.domain.Number, so my new eventHandler looks like this:
    eventHandler (Number, String)

    How to pass two values during editing of the event and how to place the payload with multiple values for the new eventHandler?

    All article or code would be greatly appreciated.

    Thanks for the help.

    You define a bean holding your values and pass an instance of the bean as a payload...

    Timo

  • How to update the value of a value in a table

    APEX - 4.1.0.00.32
    Version of DB - 10 g
    Web - OHS server architecture
    Browser - IE8
    Theme - 9

    Hello

    I have a tabular form and I want to update the value of a field using a process based on an add-on.

    the name of the column in the form of tables is (name of column P22_PROJECT_ID)

    The error I get is

    ERR-1002 unable to find point item ID 'P22_PROJECT_ID' in the application "103".

    Error unexpected, unable to find the name of the option at the page or application level.

    The field is questioned as

    Select pt.project_id P22_PROJECT_ID

    The code I'm trying to use in the process is

    : P22_PROJECT_ID: =: P10_PROJECT_ID;

    I also tried without the colon (P22_PROJECT_ID), but the application does not recognize.

    Any help would be appreciated.

    Thank you

    the tables for is on page 22?
    the project in page 10

    I think you go to page 22 page 10
    Create a new item in page 22 as p22_project_id
    Since 10 passes as a parameter the page p1o_project_id and set p22_project_id

    by default as p22_project_id

  • How can I insert instructions/text in a PDF form text field that can be typed by the end user?

    How can I insert instructions/text into a text form field that can be typed by the end user? As the screenshot attached.

    I already have a PDF (not created by me) I have to edit but cannot work out how to enter into new fields of text instructions, I create. I tried to do in InDesign, but the text gets just covered by the blue shape box when you view the final PDF file.

    Screen Shot 2015-08-07 at 10.53.10.png

    Follow the instructions as default value for the field and then reset the form.

    See also: is there a way to add instructional text to my text field that disappears when you click on? (PDF Forms)

  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • How to use as operator for several values

    Hi all

    I want to obtain the column values for the column - filed_name which ends by ('X 1', 'X 2' 'X 3' 'X 4' 'X 5' 'X 0' 'XA' 'XB' "XM" "XP" 'X' "CM" "MT") of the variable_info table


    I tried to use as shown below

    SELECT * FROM VARIABLE_INFO WHERE FieldName like (' %x 1 "," %X 0 ");

    but getting error
    ORA-00907: lack of right parenthesis

    can someone tell me how to use as operator for multiple values?

    Thank you/kumar

    You need not a subquery, just make sure that you use parentheses to group your GOLD requirements

    SELECT RELATION ,
    FIELD_NAME ,
    ATTRIBUTE ,
    FIELD_DESCRIPTION,
    SOURCE
    FROM VARIABLE_INFO
    WHERE RELATION NOT IN ( 'CHAI',  'ITAB', 'ITB2', 'ITB3', 'MINI', 'NOTE', 'MINC', 'FINI', 'FTIM', 'FWTG', 'FMLY', 'FMIS', 'FSUM', 'MEMB' ,'FINC', 'FASO')
    AND (SUBSTR(FIELD_NAME,-2) in ('X1', 'X2' ,'X3', 'X4', 'X5', 'X0', 'XA', 'XB', 'XM' ,'XP' ,'CM','MT')
      OR substr(FIELD_NAME,-1) in ('X')
      OR substr(FIELD_NAME,1) in ('J')
      )
    AND (ATTRIBUTE LIKE 'NUM%' OR ATTRIBUTE = '-') ;
    

    The error you are getting sounds like a problem with the definition of VARIABLE_INFO. It seems the synonym or something that it points to rear edge

    For example:

    CREATE SYNONYM X FOR DUAL;
    CREATE SYNONYM Y FOR X;
    CREATE OR REPLACE SYNONYM X FOR Y;
    SELECT * FROM Y;
    
    SQL Error: ORA-01775: looping chain of synonyms
    

    Kind regards
    Bob

  • How to modify and update a line later was inserted and updated in the doDML() method?

    Mr President

    Jdev worm is 12.2.1

    How to modify and update a line later was inserted and updated in the doDML() method?

    I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

    Method 1-first row in managed bean

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
            RowSetIterator rsi = dciter.getRowSetIterator();        
            Row lastRow = rsi.last();        
            int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
            Row newRow = rsi.createRow();        
            newRow.setNewRowState(Row.STATUS_NEW);        
            rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
            rsi.setCurrentRow(newRow);
            
            BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
            RowSetIterator rsi1 = dciter1.getRowSetIterator();        
            Row lastRow1 = rsi1.last();        
            int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
            Row newRow1 = rsi1.createRow();        
            newRow1.setNewRowState(Row.STATUS_NEW);        
            rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
            rsi1.setCurrentRow(newRow1); 
            
            
        }
    


    Method of doDML() of line 2 seconds in the entityImpl class


        protected void doDML(int operation, TransactionEvent e) {        
            setAmount(getPurqty().multiply(getUnitpurprice()));
           
            if (operation == DML_INSERT)  
                       {          
                         insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                           }
                           
                           if(operation == DML_UPDATE)
                           {
                               
                           updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                           }                                       
            super.doDML(operation, e);
        }
    
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
       ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                      System.out.println("sql= " + sql);    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }  
                  
                  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
       + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                      System.out.println("sql= " + sql);      
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }
    

    Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

     <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
    

    This button update the first line added by bean managed, but the second row remains unchanged.

    Please help how to update the two lines with the same button or something else.

    Concerning

    DML_UPDATE will call only if there is some change data attributes.

    I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

    I assume the update statement should look like:

      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
      {
        PreparedStatement stat = null;
        try
        {
          String sql =
            "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
            "' where VID='" + value1 + "'";
          System.out.println("sql= " + sql);
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • VSM 9.1.4 multiple values updated select via API

    Hi all

    We use a lot the VSM (9.1.4) Web service API in our Interfaces. The standard fields and 'normal' extension of work.

    Now have the obligation to insert/update a list to multiple values of selection via the api.

    As he is only mentioned anything that in the Guide of the API we tried and add several entries with the same ext_fldv to the [of CustomParamData].

    No error is thrown, but it only takes the last entry for this ext_fldv the table int.


    Has anyone of you updated a multivalued field to select via the api?


    Any suspicion on this would be be appreciated.

    ... and Yes, several values must be provided in a comma-separated string. In the example:

    Dim _ws_cust_data_list As New List (Of CustomParamData)

    _ws_cust_data_list. Add (New CustomParamData ("EXTFLDV_500102", "105,107,108"))

    Var _ws_cust_data_array() As CustomParamData = _ws_cust_data_list. ToArray()

    _ws_rq.aCustomParameters = _ws_cust_data_array



Maybe you are looking for

  • Satellite Pro L550-19 t - upgrade memory up to 8 GB

    Hello I decided to spend my laptop with 8 GB of RAM of 4 GB standard, so I bought two "Corsair 4 GB (1x4Go) DDR3 PC3 - 8500 C7 1066 MHz 204-pin SODIMM Module". I inserted the two of them into the slots and put under tension but I got a black screen.S

  • Strange behavior with Scan function

    Hi, I see some weird behaviors with the scan function.  Here's a code (for Interactive execution) window which illustrates what I'm struggling with: #include static double value;// 1234567890123456static char buffer[20] = "- 24.612 g ?"; static int s

  • Do not print

    I have a Hewlett - Packard P1006 printer, and I thought I downloaded the correct driver from HP for Windows 8.1 64bits.  My computer has the HP P 1006 shown as your default printer.  But when I want to print a word processing document and press the "

  • Install upgrade-drive HARD T42 recovery discs but hard disk starts only in routine of Rescue and Recovery.

    I am doing a new installation in what follows rather than cloning because the system has not been reinstalled for 4 years.  A CD drive external usb (internal drive deleted), I installed the recovery disks on a 160 GB Samsung HM160HC PATA drive withou

  • How I change the settings to do myself the administrator?

    Hello I just bought a Lenovo with Windows 8 desktop computer on it. I find it extremely slow despite my fast Internet connection. He keeps asking me to constantly update of software and there are ads and other pop up all the time. I wanted to downloa