Update multi lines according to a table of update

Hello!

I want to update multiple rows in a table according to a table of update like this:

key
col_a
col_b
123ABCdef
456XYZUVW
888KLMIJK

The table to be updated has this (and other) columns. I use this code to do the update:

Update my_table set t0

col_a = (select col_a updates t1 where the t1.key = t0.key)

col_b = (select col_b from t1 updates where the t1.key = t0.key)

where

key (select updates button);

It works very well, but...

.. .it seems to be ineffective. It seems that the systems needed to create keys in the table updates. He must then go through my_table and search the table updates twice for each update. Right? OK, the system can optimize it. I hope that. Is it possible to see how the system will perform the foregoing.

.. .is too laborious to write in code. Is there a better way to specify:

"For any row from my_table where the key is the key of table updates, updates col_a and col_b my_table with values according to table updates?

THX!

Hello

1010848 wrote:

Hello!

I want to update multiple rows in a table according to a table of update like this:

key
col_a
col_b
123 ABC def
456 XYZ UVW
888 KLM IJK

The table to be updated has this (and other) columns. I use this code to do the update:

Update my_table set t0

col_a = (select col_a updates t1 where the t1.key = t0.key)

col_b = (select col_b from t1 updates where the t1.key = t0.key)

where

key (select updates button);

It works very well, but...

.. .it seems to be ineffective. It seems that the systems needed to create keys in the table updates. He must then go through my_table and search the table updates twice for each update. Right? OK, the system can optimize it. I hope that. Is it possible to see how the system will perform the foregoing.

.. .is too laborious to write in code. Is there a better way to specify:

"For any row from my_table where the key is the key of table updates, updates col_a and col_b my_table with values according to table updates?

THX!

FUSION is often more effective than the UPDATE, precisely for the reasons you mentioned.

Try using the MERGER: http://docs.oracle.com/database/121/SQLRF/statements_9016.htm#sthref7153

something like:

MERGE INTO my_table mt

USING update u

WE (mt.key = u.key)

WHEN MATCHED THEN UPDATE

SET mt.col_a = u.col_a

mt.col_b = u.col_b,

;

If you would care to post a small example of data (CREATE TABLE and INSERT statements for both tables) and outcomes from this data, I was able to test this.

Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

Tags: Database

Similar Questions

  • multi line based on LOV table insert

    SEQ / / desc Ref number value of the option of lov to insert
    15DESC 1011
    16DESC 2022
    17033
    18044
    19055
    20.... 6067

    I have table, need multi line unique insert in process.there is a lov as values from 1 to 10 as number.when return value I select LOV (for example selected value 7) then the rows inserted in table 1 to 7 lines only.the table sequence number must increment as well use.

    Well, if your "seq by trigger" is a sequence number created via a trigger, then you don't need to add yourself as the trigger must do.

    You can then insert the number of rows you want, based on the input parameters...

    Suppose that your values in the apex are: OPT_NUMBER and: SL_NUMBER

    Insert into tablename (option_seq_num, sl_number)
    Select to_char(level,'fm09')
    ,: sl_number + (level-1)
    of the double
    connect by level<=>

    Example of the data...

    SQL > ed
    A written file afiedt.buf

    1 Select to_char(level,'fm09')
    2, & sl_number + (level-1)
    3 double
    4 * connect by level<=>
    SQL > /.
    Enter the value for sl_number: 0
    2 old:, & + sl_number (level-1)
    2 new:, 0 + (level-1)
    Enter the value of opt_number: 10
    4 old: connect by level<=>
    new 4: connect by level<=>

    TO_ 0 + (LEVEL-1)
    --- -----------
    01            0
    02            1
    03            2
    04            3
    05            4
    06            5
    07            6
    08            7
    09            8
    10            9

    10 selected lines.

  • Derivative of af: line according to requirement table

    Hi Experts,

    I am a developer using J 11.1.1.5.0,

    My scenario is,

    I have a page Jsff, jsff page have an af:table. In this table with a 100 lines,.

    My need is want to highlight the row in the table in different color based on column values.

    How to get there

    someone suggest me.

    Thank you

    There are some samples for this as the implementation of cell highlighting in JSF Rich Enterprise Applications and Andrejus Baranovskis Blog: changed line highlighting in Oracle ADF Table

    The trick is to set the background via a bean method that can decide what color to return based on the values of the row.

    Timo

  • How to get a multi line region to call a procedure on each row updated

    Hi all

    I want to offer the possibility of reparenting a certain number of rows in a table. Fix routine is a pl/sql package procedure.

    What I want to do is see the kids lines in a region, and then select a new parent (if a child is in need of a new parent). Then, I want to deal with all the lines by calling the procedure where a change to the parent company did.

    If there is a way to do this? (And if all goes well, it is clear that I am doing).

    Basically: Multi line form, can I use a procedure on each line that I want to update when I select Apply Changes?

    Kind regards
    Steve

    Published by: spilgrim on June 25, 2009 15:15

    Steve,

    You can do more things with tabular shapes when you understand more about how they work. The approach varies a bit depending on whether you leave Apex manage them or do it manually, but the concepts are the same.

    When the page is sent to you get a series of paintings dealing with the page that discusses the section:
    http://download.Oracle.com/docs/CD/E14373_01/apirefs.32/e13369/apex_app.htm#CHDICJDA

    Denes Kubicek has a few good demos on this point, a here:
    http://HTMLDB.Oracle.com/pls/OTN/f?p=31517:170

    You need to browse looping with these berries calling your procedure every time. However, it is not really easy the first time you do it.

    Kind regards
    Dan

    http://danielmcghan.us
    http://sourceforge.NET/projects/tapigen
    http://sourceforge.NET/projects/plrecur

    You can reward this answer by marking as being useful or correct ;-)

  • multi line / rowspan header table

    I need a table with a head composed of multiple rows and columns.

    Is this possible with CVI and if so, how?

    Column headers or a table row can be multiline like (almost) any other item of text in CVI signs: you can get part by pressing Ctrl + enter if you change the text in the editor of the IUR. You need to increase the size of header to fitthe newlabel line.

    However, unfortunately it is not possible to have more than one header line in the native tables of CVI. In addition, it is not possible to merge cells on some lines as you can do in Excel, so when I need a setting more complicated for the headers I normally use a separate to table it. The table "header" is defined as an indicator, and I put the cell widths according to my needs.

    You can see the two tricks in this example:

  • Multi line form and onload

    Hello

    I have a Multi line form (MRF) function wizard based on views (2 tables) with instead of triggers to manage the DML. I have an onchange event on a particular list item select according to each line that simply enables / disables other line items according to the value. It all works well, but I need to repeat the toggle points for each line, once the page is loaded.

    My first thought is to use an event onload in the definition of the Page, but cannot, and should I handle this in a process Page instead (keep in mind that he is a wizard generated MRF)? Also, I need to check that the new lines (via the Add Row button) are managed properly. If I go down the route of onload event, then is the easiest just to get a table (getElementsById?) of items and loop through them? Any thoughts would be most appreciated on the most effective way to do.

    See you soon,.

    PaulB

    Hello

    Yes, it appears same as an onload but, fortunately, does not interfere with any existing onload code - you can have only a single function of the window object onload call.

    You can iterate through the items in the form using something like:

    function disableItems()
    {
    var x = document.getElementsByName("f03");
    var y = document.getElementsByName("f04");
    for (int k = 0; k < x.length; k++)
    {
     if (x(k).value == 'A')
     {
      y(k).disabled = true;
     }
     else
     {
      y(k).disabled = false;
     }
    }
    }
    

    This assumes that the selection list is in column 3 (which should mean that SELECT objects must have a name of "f03" attribute) and that the element you want to toggle is in column 4 ("f04") - so adjust as needed.

    Like you have the same number of items in the column 3 and column 4 - loops above through those in column 3, checks the selected value, and then activates / deactivates the item in the same row in column 4.

    Andy

  • Lines left in the table LT after removal of the direct workspace and the removal of all workspaces

    I had a lot of data in a table enabled version that has been modified in some workspaces.  The LIVE workspace, I deleted all the rows in the table and I then drove back the workspaces (yes I probably should have done differently).  Once workspaces have been cancelled table LT empty, I would have expected, but it wasn't.

    I can reproduce this in the example below.  I insert two lines in the test table and allow it to version.  In a workspace I update a row in the table, which leads to 3 ranks in LT as expected.  Live, I delete the two lines of the table that translates into 5 lines of LT which is fine.  So I restore and delete the workspace I created for the update.  At this point, nothing should versioned LT lines, so I expect to go, but two lines remain.  In my real-world scenario, it is initially questions as the table LT is now much more it must be and requests on the versioned table are slow.

    Is this expected behavior?  Can I do anything to clean?

    Thank you

    John

    scott@JOHNOT> select * from v$version;
    
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    PL/SQL Release 11.2.0.4.0 - Production
    CORE    11.2.0.4.0      Production
    TNS for 64-bit Windows: Version 11.2.0.4.0 - Production
    NLSRTL Version 11.2.0.4.0 - Production
    
    
    scott@JOHNOT> create table test_wm_table (
      2    id number primary key,
      3    name varchar2(20));
    
    
    Table created.
    
    
    scott@JOHNOT> execute dbms_wm.enableVersioning('test_wm_table');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> insert into test_wm_table (id, name) values (1, 'first value');
    
    
    1 row created.
    
    
    scott@JOHNOT> insert into test_wm_table (id, name) values (2, 'second value');
    
    
    1 row created.
    
    
    scott@JOHNOT> commit;
    
    
    Commit complete.
    
    
    scott@JOHNOT> select * from test_wm_table_lt;
    
    
            ID NAME                    VERSION NEXTVER     DELSTATUS LTLOCK
    ---------- -------------------- ---------- ---------- ---------- ------------------------
             1 first value                   0 -1                 10 *-1,-9,-1*$#SCOTT$#
             2 second value                  0 -1                 10 *-1,-9,-1*$#SCOTT$#
    
    
    scott@JOHNOT> execute dbms_wm.createWorkspace('test_workspace');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> execute dbms_wm.goToWorkspace('test_workspace');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> update test_wm_table set name = 'something else' where id = 1;
    
    
    1 row updated.
    
    
    scott@JOHNOT> commit;
    
    
    Commit complete.
    
    
    scott@JOHNOT> select * from test_wm_table_lt;
    
    
            ID NAME                    VERSION NEXTVER     DELSTATUS LTLOCK
    ---------- -------------------- ---------- ---------- ---------- ------------------------
             1 first value                   0 ,45,               10 *-1,-9,-1*$#SCOTT$#
             2 second value                  0 -1                 10 *-1,-9,-1*$#SCOTT$#
             1 something else               45 -1                 11 *0,10,0*$#SCOTT$#
    
    
    scott@JOHNOT> execute dbms_wm.gotoworkspace('LIVE');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> delete test_wm_table;
    
    
    2 rows deleted.
    
    
    scott@JOHNOT> commit;
    
    
    Commit complete.
    
    
    scott@JOHNOT> select * from test_wm_table order by id;
    
    
    no rows selected
    
    
    scott@JOHNOT> select * from test_wm_table_lt order by id;
    
    
            ID NAME                    VERSION NEXTVER     DELSTATUS LTLOCK
    ---------- -------------------- ---------- ---------- ---------- ------------------------
             1 first value                   0 ,44,45,            10 *-1,-9,-1*$#SCOTT$#
             1 something else               45 -1                 11 *0,10,0*$#SCOTT$#
             1 first value                  44 -1                -11 *-1,-9,0*$#SCOTT$#
             2 second value                 44 -1                -11 *-1,-9,0*$#SCOTT$#
             2 second value                  0 ,44,               10 *-1,-9,-1*$#SCOTT$#
    
    
    scott@JOHNOT> execute dbms_wm.rollbackWorkspace('test_workspace');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> execute dbms_wm.removeWorkspace('test_workspace');
    
    
    PL/SQL procedure successfully completed.
    
    
    scott@JOHNOT> select * from test_wm_table order by id;
    
    
    no rows selected
    
    
    scott@JOHNOT> select * from test_wm_table_lt order by id;
    
    
            ID NAME                    VERSION NEXTVER     DELSTATUS LTLOCK
    ---------- -------------------- ---------- ---------- ---------- ------------------------
             1 first value                   0 -1                -11 *-1,-9,0*$#SCOTT$#
             2 second value                  0 -1                -11 *-1,-9,0*$#SCOTT$#
    
    
    

    Post edited by: John OToole

    OK, I see.

    Options (depending on the structure of your current workspace if it is not as simple as in the example) are rollback, purgetable or compressworkspace.

    More information on when and how to use them can be found in this thread: https://community.oracle.com/message/4027735#4027735

    Rollback works in your example, certainly, but might not be applicable in a real scenario.

    Hope that helps.

    Kind regards

    Andreas

  • Allowing the movement line temporarily on partitioned table

    Hello

    Using oracle 11.2.0.3 and have tables that are hash of composite range partitioned.

    We need to update the dates of theses for a small percentage of records 1 < %.

    Normally we have movement line enabled so that can copy the lines in the temporary table, update insert_table, remove lines concerned living table and replace them with the new dates of the partition.

    Another option allowing possibly temporariliy movement line.

    Thoughts?

    Thank you

    Is there any disadvanatges to allowing it for example from performance perspective.

    Haerd was a bad iade of have it activated - perhaps isn't so bad.

    Tom Kyte meets ALL these questions (and more) in this blog:

    https://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:35203106066718

    If never actually cause you a row to move, then there is zero overhead. All the movmement of line enable does is give us permission to move a line, if you do not ask us to move the line - extra "nothing happens.
    . . .

    Follow-up Friday, March 10, 2009-02:00 UTC:

    Is there something wrong? Only you can answer that you have any application that expects the rowid is constant for a line? If yes - then it is false, if not - then it's probably OK.

    Any overload? No, it's just allowed to change a rowid if you perform an operation that would have caused a rowid to change - alter table t shrink compact space, flashback table t to..., update t set partition_key = some_value_that_moves_row;

    You can change a table instantly to activate circulation line - whatever the size of the table - it'll be instant - you have no need to do advance if you don't want, fairly easy to add later...

    I recommend you to read the ENTIRE blog because there are many other issues that should relieve your concerns and good examples.

    As says this quote above if you have an application that expects the ROWID is constant for a line, then you might have a problem.

    ROWID is the way the FASTER to search for a line. Sometimes the ETL process are complex and multiple operations on a line by multiple, separate steps.

    You can often get huge performance gains in saving the values ROWID lines collections or tables of work/temp during ETL processing. For example, a query in PL/SQL can use ' RETURN ROWID IN... "to get all of the ROWID that affects the query.

    This set of ROWID can be used in the following queries to locate the exact lines directly without the need of ALL indexes or other search criteria: WHERE ROWID IN...

    If the ROWID has changed during the process, it would be disastrous if these processes are written in:

    1. Enter the current setting of moving the line

    2. turn off the movement of the line during the process

    3 re-enable line movement ONLY if it has been activated prior to the start of the process

  • Add lines to insert a table based on the box and the values in the LOV

    I have two options (1) the list of values (2) box (2 values) .the are required field.when I click on create lines button and then insert table/slot (fire) form of table, based on my selected lov values (for example 3 selected then 3 rows only) and the value of the checkbox.

    If I select 3 values LOV and then check the box 1

    SEQ / / desc box SL (1)
    1DESC 11
    2DESC 22
    3DESC 33

    If I select 5 values LOV and then check the box 0

    Header 1 / / desc box SL (0)
    1DESC 10
    2DESC 21
    3.. 5DESC 3... 52.. 5

    my workspace: ram_r & d

    username/password: aramani/apex

    App: https://apex.oracle.com/pls/apex/f?p=72423:1:102019883635814:NO

    Thank you

    RAM

    It has achieved the goal, thread:multi line table based on LOV

  • White line how unwanted continuous table titles?

    I managed to use a white rectangle to hide the "BOLD" line junk above table titles except when the table continuation variable is used for the tables continued on a second page. All the world has discovered a work around?

    bold line unwanted above the table titles

    Assuming you are using the default table definitions, have you tried to update the TableTitle style? or decision in the table style properties?

    I do not use the definitions by default, though I've never seen a title with a line in bold above. Maybe you could put a picture.

  • How to build a JTree with nodes multi-line Windows L and am FJt

    Although I already found 2 ways to build nodes multi-line JTree but both methods work very well in Java by default appearance and when I change my windows look and feel then it fails. I can't understand what is the problem. The two ways by which I build multi line nodes are:

    First: Using html in nodes
    as the DOSB linea < br > < html > < / html >

    Secondly: By implementing TreeRenderer and change it accordingly, such a class is given below
    class ModifiedTreeCellRenderer extends JPanel implements TreeCellRenderer {
        protected JLabel icon;
        protected TreeTextArea text;
        
        public ModifiedTreeCellRenderer() {
            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            icon = new JLabel() {
                @Override
                public void setBackground(Color color) {
                    if (color instanceof ColorUIResource)
                    color = null;
                    super.setBackground(color);
                }
            };
            add(icon);
            add(Box.createHorizontalStrut(4));
            add(text = new TreeTextArea());
        }
        
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            String stringValue = tree.convertValueToText(value, isSelected, expanded, leaf, row, hasFocus);
            setEnabled(tree.isEnabled());
            text.setText(stringValue);
            text.setSelect(isSelected);
            text.setFocus(hasFocus);
            if (leaf) {
                icon.setIcon(UIManager.getIcon("Tree.leafIcon"));
            } else if (expanded) {
                icon.setIcon(UIManager.getIcon("Tree.openIcon"));
            } else {
                icon.setIcon(UIManager.getIcon("Tree.closedIcon"));
            }
            return this;
        }
    
        @Override
        public Dimension getPreferredSize() {
            Dimension iconD = icon.getPreferredSize();
            Dimension textD = text.getPreferredSize();
            int height = iconD.height < textD.height ? textD.height : iconD.height;
            return new Dimension(iconD.width + textD.width, height);
        }
    
        @Override
        public void setBackground(Color color) {
            if (color instanceof ColorUIResource)
                color = null;
            super.setBackground(color);
        }
    
        class TreeTextArea extends JTextArea {
            Dimension preferredSize;
            
            TreeTextArea() {
                setLineWrap(true);
                setWrapStyleWord(true);
                setOpaque(true);
            }
    
            @Override
            public void setBackground(Color color) {
                if (color instanceof ColorUIResource)
                color = null;
                super.setBackground(color);
            }
    
            @Override
            public void setPreferredSize(Dimension d) {
                if (d != null) {
                preferredSize = d;
                }
            }
    
            @Override
            public Dimension getPreferredSize() {
                return preferredSize;
            }
    
            @Override
            public void setText(String str) {
                FontMetrics fm = getToolkit().getFontMetrics(getFont());
                BufferedReader br = new BufferedReader(new StringReader(str));
                String line;
                int maxWidth = 0, lines = 0;
                try {
                    while ((line = br.readLine()) != null) {
                        int width = SwingUtilities.computeStringWidth(fm, line);
                        if (maxWidth < width) {
                            maxWidth = width;
                        }
                        lines++;
                    }
                } catch (IOException ex) {
                    System.out.println(ex);
                }
                lines = (lines < 1) ? 1 : lines;
                int height = fm.getHeight() * lines;
                setPreferredSize(new Dimension(maxWidth + 6, height));
                super.setText(str);
            }
    
            void setSelect(boolean isSelected) {
                Color bColor;
                if (isSelected) {
                    bColor = UIManager.getColor("Tree.selectionBackground");
                } else {
                    bColor = UIManager.getColor("Tree.textBackground");
                }
                super.setBackground(bColor);
            }
    
            void setFocus(boolean hasFocus) {
                if (hasFocus) {
                    Color lineColor = UIManager.getColor("Tree.selectionBorderColor");
                    setBorder(BorderFactory.createLineBorder(lineColor));
                } else {
                    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
                }
            }
        }
    }
       
    but the two methods in the event of failure in a Windows look and feel, can anyone help with this?

    Published by: user8978073 on April 30, 2011 10:24

    Published by: user8978073 on April 30, 2011 10:25

    Can't check right now, but - afair, windowsLAF sets the rowHeight to a fixed value (16 or 18 or something like that). Consult the setRowHeight and make sure that there<= 0="" to="" indicate="" that="" it="" should="" be="">

  • Bug? : function in the form "addRow" can't handle multi-line model line

    Hi all

    I created a custom report (model line named column) model which creates 2 lines per registration type (which is actually 2 lines in a HTML table).

    In the APEX feature initTabForm (apex_4_0.js) the line of the sample (f01_0000) is read and stored in gTabFormInitRow

    This is done using a selector to jQuery like this: jQuery('#init_row_'+pRegionID) which returns only the first line of my multi-line record.

    This behavior is expected, or is this a bug? Or do I have to change my HTML structure?

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    Work: http://www.click-click.at
    Training: http://www.click-click.at/apex-4-0-workshops

    Peter,

    This is the expected behavior. It would be impossible to anticipate all HTML structure customers would like to use in their models, on the other hand, although we do not want to keep open and not to lock these models. So in your case, I suggest to go with a table nested in the TR line, this way you can keep your single-TR by sub LINE shape, yet within these lines, have your own table structure.

    Kind regards
    Marc

  • Refresh the components within a specific line of an af:table programmatically

    How do I refresh the components within a specific line of an af:table programmatically without refreshing the entire table? _

    I have an af:table to display a view read-only object. There is a button change in the table by calling an af:popup, where the user can update the information and click on a submit button to commit its changes.
    The action of this button property is a method in a holder in the summer where
    -1: a stored procedure is called to update several tables (related to my read-only VO).
    -2: the VO is re-interviewed (refreshQueryKeepingCurrentRow() VO.)
    -3: updating of the whole table (AdfFacesContext.getCurrentInstance () .addPartialTarget (myTable))

    Is it possible to programmatically refresh some components of the current row in the table without refreshing the entire table (point 3)?

    I tried to play with the property "partialTrigger" to af: outputText (table: column: outputText), without success.

    Thank you

    Nicolas

    OK, that's a very clear answer, thank you.

    Now, first do a little optimization:

    if(!StringUtils.isStringEmpty(results) && results.equals("TRUE"))
    // should be
    if ("TRUE".equals(results))
    // since it's faster, simpler and requires one less dependency
    

    For your use case, you can say you want to always refresh the line, then you could link the table in your backing bean, retrieve the selectedRowKeys and then set the key for the current line on the model in the collection before adding the partial target. So, something like:

    Set selectedKeys = table.getSelectedRowKeys();
    assert selectedKeys.size() == 1;
    Object old = table.getRowKey();
    try
    {
        table.setRowKey(selectedKeys .iterator().next());
        addPartialTarget(outputText);
    }
    finally
    {
        table.setRowKey(old);
    }
    
    

    p.s. I checked the table rendering code to be sure and partial updating of the contents of the line must be possible without refreshing the entire table.

    Kind regards

    ~ Simon

  • Multi lines convert to a single line

    Dear Group members
    I want to convert the queries that return multiple lines in a single line. Scanario is provided for in
    select * from inout v
    where v.empcode = '00047'
    and v. dated = '27-dec-09'
    
    EMPCODE      DATED        IN_TIME   NET_TIME     ATT_STATUS     VAL
    00047     27/12/2009     0     0       G             1
    00047     27/12/2009     0     0       R             1
    00047     27/12/2009     7.44     483       P             1
    This query gives multi lines, but I would like to convert it into a line like this
    EMPCODE      DATED        IN_TIME   NET_TIME     ATT_STATUS     VAL
    00047     27/12/2009     7.44     483       R             1
    If the employee came the day that has three traffic status ('G', 'R', 'P'), then it should show in_time, net_time situation and their participation should be 'R '.

    In this example there are two rows. I need the line that has in_time > 0, which is the 2nd bet replaces att_status 'P' for 'R '.
    EMPCODE      DATED        IN_TIME   NET_TIME     ATT_STATUS     VAL
    00047     25/12/2009     0     0       R             1
    00047     25/12/2009     7.59     476       P             1
    Suppose that there are the 25/12/2009 and employee came that day then it shows the following result.
    EMPCODE      DATED        IN_TIME   NET_TIME     ATT_STATUS     VAL
    00047     25/12/2009     7.59     476       R             1
    It presents 'R' Att_status coloums instead of 'P '.

    >
    Note that
    'G' = blew in gusts
    'R' = rest
    "P" = present
    >

    Test case is provided for in
    CREATE TABLE INOUT
    (
      EMPCODE     VARCHAR2(10),
      DATED       DATE,
      IN_TIME     NUMBER(10,2),
      NET_TIME    NUMBER(10,2),
      ATT_STATUS  VARCHAR2(5),
      VAL         NUMBER(3)
    )
    
    insert into inout(EMPCODE,    DATED     ,IN_TIME , NET_TIME, ATT_STATUS, VAL  )
    values           ('00047','25-DEC-2009',     0    ,       0     ,   'R' ,           1);
    insert into inout(EMPCODE,    DATED     ,IN_TIME , NET_TIME, ATT_STATUS, VAL  )
    values           ('00047','25-DEC-2009',     7.59 ,       476   ,   'P' ,           1);
    insert into inout(EMPCODE,    DATED     ,IN_TIME , NET_TIME, ATT_STATUS, VAL  )
    values           ('00047','27-DEC-2009', 0    ,    0         ,   'G'     ,       1);
    insert into inout(EMPCODE,    DATED     ,IN_TIME , NET_TIME, ATT_STATUS, VAL  )
    values           ('00047','27-DEC-2009',     0    ,       0     ,       'R'     ,       1);
    insert into inout(EMPCODE,    DATED     ,IN_TIME , NET_TIME, ATT_STATUS, VAL  )
    values           ('00047','27-DEC-2009',     7.44 ,       483   ,       'P' ,           1);
    Thanks and greetings
    select distinct empcode,dated,
           case when cnt>0 then
             max(in_time) over (partition by empcode,dated)
            else
               in_time
            end in_time,
           case when cnt>0 then
             max(net_time) over (partition by empcode,dated)
            else
               net_time
            end net_time,
    
           case when cnt >0 then
               case when status in  ('G','P','R')  then
                'R'
                    when status in ('HCP','1/2') THEN
                'HCP'
               end
             else
               status
            end status
           from (
            select v.empcode,v.dated,v.in_time,v.net_time,(count(*) over (partition by v.empcode,v.dated)) cnt,att_status status
             from inout v
            where v.empcode = '00047')
    

    Published by: Khaled Aradhye, January 20, 2010 02:23

  • line selected in the table in jdev11

    I have listener custom selection for table to do things according to the selected line, but when the table has a single row of this line is automatically selected my interlocutor of choice is not triggered, so my question is how to accomplish that, initially, no row is selected in the table?

    Depends on the use case, but you can do this by deleting the attribute selectedRowKeys of the table.

    Pedja

  • Maybe you are looking for