In the form of table-update a column based on the other

Greetings,

I want to update a column based on the value of another column in a tabular presentation. What should I use? Calculation or validation process?

-Vatsa

Yes, get rid of the update of "pims_component" - this is the cause of the error table mutation - and simply set

: new.state_ind: = Ls_state;

CITY

Tags: Database

Similar Questions

  • In the form of table-update of rows based on the selection of the checkbox

    Hi all

    I have a tabular layout with line selector. I need to update manually checked columns, how would write a process audited records updated?

    Something like this:
    BEGIN     
         FOR i in 1..apex_application.g_f01.count LOOP
    
              IF apex_application.g_f01(i) is not null THEN
                   UPDATE TEST_USERS
                        set USER_ID = :P14_TO
                   WHERE rowid = :APEX$ROW_ID;
                   COMMIT;
              END IF;
         END LOOP;
    END;
    Thank you very much.

    You can refer to the line that you want to process through the value stored in the box.

    If you use apex_application.g_f01 (i) to make reference to the line and you want to update the row based on the ROWID in your request, your SQL query should have the box as follows:

    apex_item. CheckBox2 (1, rowid)

    Then your PLSQL process would be like this:

    BEGIN
         FOR i in 1..apex_application.g_f01.count LOOP
    
              IF apex_application.g_f01(i) is not null THEN
                   UPDATE TEST_USERS
                        set USER_ID = :P14_TO
                   WHERE rowid = APEX_APPLICATION.G_F01(i);
                   COMMIT;
              END IF;
         END LOOP;
    END;
    

    I hope this helps.

    Cheers, Pete

  • Compare multiple columns and update a column based on the comparison

    Hi all

    I have to update the column STATUS of the slot structure of the table.

    Status should be 'P' if all the columns count are equal on the other should be "F".

    The value of the column can be "NA'. If the value is NA, then avoid this comparison column; compare only other 3 columns.

    My output should look like below.

    State of cnt1, cnt2 cnt3 ID cnt4

    1   4       4       4     4       P

    2   4       5       4     4       F

    3 4 4 NA 4 P

    NA 4 4 3 4

    I tried with the statemnt with BOX WHEN conditions and DECODE UPDATE, but could not succeed, can someone please help

    To do this, if you use my statement in response #11 box (Re: Re: comparison of multi-column and update a column based on the comparison of)

  • update of column based on the values of the same table

    I have the T1 table with 4 columns "col1", "col2", "col3", "col4", "col5", "col6" as follows

    Col1 Col2 Col3 Col4 Col5 Col6
    1111 Ville1 C AA DDD A1
    2222 city SD HHH A1 1
    3333 City2 B EE OOO
    4444 City 1 B JJ SSS A1
    5555 City2 C KK VVV
    6666 City2 RR QQQ
    7777 City2 B BBB XX

    I've already updated column value 6 'A1' where the 2 column is 'Ville1 '.

    Now, I want to update Col. 6 where col2 is the of ' with the following conditions
    If Col 3 = 'B', then Col6 should be = col4
    Otherwise, it should be = col5

    SET col6 = DECODE(col3,'B',col4,col5)
    "WHERE col2 = s"

  • update of column based on another column

    Hi all

    I want to update the column 2 of the table based on the value of update in column 1 and the existing value in column 1

    Assume that table1 has columns ID, col1 and col2

    I update col2 based on the update to col1 value and comparing the existing value of col1 in the table.

    trying to decode, I think it should work.

    Thank you.

    Not like that.

    You change a column of type CHAR, VARCHAR2 column, right? Thus, the data will be same. (Completed with space). For the new data inserted into a column VARCHAR2 TRIM is not necessary.

  • update of column based on the sum of the data from another table

    I have two tables:

    Table1 (col1, col2, col3, col4, val1, status) Table2 (col1, col2, col3, col4, val2)

    For Table1 and Table2, column (col1, col2, col3, col4) are the primary key of composit.

    Table2 could have duplicated lines, that's why I want to group by (col1, col2, col3, col4) and sum (val2)

    After that, I want to update Table1.val1 with the value of sum (Table1.val2) where Table1.col1 = Table2.col1 and Table1.col2 = Table2.col2 and Table1.col3 = Table2.col3 and Table1.col4 = Table2.col4 and status = 'V '.

    I did something like this:

    UPDATE Table1 SET val1 = (

       

    WHERE Table1.col1 = t_sommevbrute.col1 and Table1.col2 = t_sommevbrute.col2 and Table1.col3 = t_sommevbrute.col3 and Table1.col4 = t_sommevbrute.col4)

    Could someone help me please? Thank you

    merge into table1 t1

    using (select col1, col2, col3, col4, sum (val2) val2

    from table2

    Group

    by col1, col2, col3, col4) t2

    on (t1.col1 = t2.col1 t1.col2 = t2.col2 and t1.col3 = t2.col3 and t1.col4 = t2.col4 and)

    When matched then

    update set t1.val1 = t2.val2;

  • Update a column-based

    Hi all

    Let us examine below in Oracle 11 g:

    create table xx_test1 (line_num  number, line_group_num number, type varchar2(25));
    
    
    insert into XX_TEST1 values('',1, 'ITEM');
    insert into XX_TEST1 values('',1, 'TAX');
    insert into XX_TEST1 values('',2, 'ITEM');
    insert into XX_TEST1 values('',2, 'TAX');
    insert into xx_test1 values('',3, 'ITEM');
    insert into xx_test1 values('',3, 'TAX');
    

    I want the line_number update based on type and line_group_num columns column.

    So necessary result:

      LINE_NUM LINE_GROUP_NUM TYPE
    ---------- -------------- ----
             1              1 ITEM 
             2              2 ITEM 
             3              3 ITEM 
             4              1 TAX  
             5              2 TAX  
             6              3 TAX  
    

    That means I want the sequence to be - items in the first place, only the lines of the TAX.

    Line_group_number is the column that combines the tax line to the line item.

    Any ideas?

    Regrads,

    Stoyanov.

    Hello

    user11340233 wrote:

    Hi all

    Let us examine below in Oracle 11 g:

    1. create table xx_test1 (type number line_num, line_group_num, varchar2 (25));
    2. insert into XX_TEST1 values (", 1,"ITEM");
    3. insert into XX_TEST1 values (", 1,"TAX");
    4. insert into XX_TEST1 values (", 2,"ITEM");
    5. insert into XX_TEST1 values (", 2,"TAX");
    6. insert into xx_test1 values (", 3,"ITEM");
    7. insert into xx_test1 values (", 3,"TAX");

    I want the line_number update based on type and line_group_num columns column.

    So necessary result:

    1. TYPE OF LINE_GROUP_NUM LINE_NUM
    2. ---------- -------------- ----
    3. 1 1 ARTICLE
    4. 2 2 POINT
    5. 3 POINT 3
    6. 4 1 THE TAX
    7. 5 TAX 2
    8. 6 TAX 3

    That means I want the sequence to be - items in the first place, only the lines of the TAX.

    Line_group_number is the column that combines the tax line to the line item.

    Any ideas?

    Regrads,

    Stoyanov.

    You can do this by using the ROW_NUMBER function analytical in a MERGE statement.  For example:

    MERGE INTO dst xx_test1

    WITH THE HELP OF)

    SELECT line_group_num, type

    ROW_NUMBER () (ORDER BY TYPE, line_group_num) AS line_num

    OF xx_test1

    )              src

    WE (dst.line_group_num = src.line_group_num

    AND dst.type = src.type

    )

    WHEN MATCHED THEN UPDATE

    SET dst.ine_num = scr.line_num

    ;

    This assumes that the combination (type, line_group_num) is unique, and none of these columns are NULL, like your sample data.

    If this isn't the case, then the above statement needs to be changed a little, but only a louis577.

  • Comparison of column in the form of table II

    Hello

    At the APEX 4.1 I am doing something similar to this thread: in table form: compare two fields in column where I need to do a validation on two columns in tabular form. It works for both columns are columns of text box, but I can't make it work when comparing to a single column to display. For validation, I have defined it as an "Expression of PL/SQL" and my expression is: CURRENT_VALUE >: PREV_VALUE where CURRENT_VALUE is a column of text box that accepts user input and PREV_VALUE is only one display column.

    Regardless of the absorbed power, the row is updated without any errors raised; He seems to treat the single display value in the vacuum and made the comparison with an empty value. The only solution I could find was to make the comparison in a update trigger on and will raise an error if validation fails; but the result is not as nice as the built in features of validation of the APEX.

    No indication on how to make it work using the validation of the APEX is greatly appreciated.

    Thank you!

    Only column display are for display only and are not saved in the session when you send, so that you can't access with pl/sql.

    So either do the validation in javascript/jQuery or, and it is best if you ask me, make a text field and set to read-only.

  • How to upgrade only the UPDATED / CHANGED column in a FORM

    Hello

    I have a FORM that is based on a table to say... TABLE1:
    When create/apply changes.. .He calls the default process DML and does the insert/update of the TABLE1 table.

    at the same time, I have other processes PL\SQL... who does the insert/update manual in the other table... TABLE2 for some pulse columns col1, col2, col3...

    When I'm in UPDATE mode and have not changed the column col1, col2, col3... even my next manual update will be pulled... The AUDIT is run, and it updates the last_update_date & last_updated_by...
    HOW TO AVOID THIS PROBLEM?
    update table2
         set col1 = :p_col1, 
              col2 = :p_col2, 
              col3 = :p_col3
    Thank you
    Deepak

    Deepak,

    You can change your trigger to address this issue...

    IF :new.col1 != :old.col1 OR  :new.col2 != :old.col2 OR  :new.col3 != :old.col3
    THEN
    :new.last_updated_by := v('APP_USER');
    :new.last_updated_on := SYSDATE;
    END IF;
    

    See you soon,.
    Hari

  • How to update exists column on the table with the exact number and auto increment

    Hello

    I have a table with more than 10 million rows and there is a column called 'number_zaq', I want to update this column on line frist from 2000 and + 1 for the next all ranks.

    Update your_table

    Set number_zaq = rownum + 2000-1;

  • If the default value in columns on slot form of table does not work.

    Hello

    I created a tabular form and I want to set some default values to columns that are based on the values of page elements.

    so I put the page element to the value of the column in the attributes in a table by selecting the value & P24_ISSUE_ID. default type as Expression PLSQL & DEFAULT function there but
    in the same way, I tried for the other column by selecting the type default as pl/sql expression and function by default the value & P24_CASE_NAME.

    but it throw an error of this type could not parse the SQL query: ORA-00904: "C254DB": invalid identifier

    I don't understand where I did wrong, I checked for the data types of columns, all right.

    so please help me out of this problem.

    1243 Tulasi wrote:
    for the first column

    I chose
    The DEFAULT TYPE as PL/SQL Expression & FUNCTION

    As the default * & P24_ISSUE_ID.* it is a number data type column

    2nd column

    The default Type as PL/SQL Expression & function

    As the default * & P24_CASE_NAME.* it's column of type Varchar2.

    Element (name of the page element or application) for the default Type and the name of the default item ( P24_ISSUE_ID, P24_CASE_NAME etc.) options appropriate for a default value for a page element.

    * & P24_ISSUE_ID.* is not a "PL/SQL Expression or function.

    but it throws an error, because this guy could not parse the SQL query: ORA-00904: "C254DB": invalid identifier

    What you're doing results in the engine of the APEX, P24_CASE_NAME 'C254DB' value in the default value and then try to assess this string as a piece of PL/SQL. Outside a block in which it is defined as a variable, constant, or a function 'C254DB' is not a valid expression of PL/SQL.

  • Column of link does not work on a manual in the form of table

    Hello

    I'm having some problems by creating a link on a column based on a tabular presentation manual (I use Apex 4.1.1.00.27, Oracle DB 10.2.0.5.0):

    On my 1 page, I created a method that deletes and creates a collection based on the table 'emp '; Then I have a manual tabular presentation based on this collection; and finally, a link in the column "deptno" of the manual tabular form that points to my Page 2 (form of Department) and is passing the P2_DEPTNO parameter: #DEPTNO #.

    The problem is that when I press on the link, the page does not present the value of DEPTNO. In addition, I note that as soon as I specify the column as a column of link, it does not show the value in the form of my table, but if I remove the link, it shows the value correctly.

    I created an example on apex.oracle.com in case some of you want to look at the question:
    Workspace: EDIAZJORGE
    User name: test
    Password: test123
    App name: Sample App
    Number of app: 12231

    I appreciate any ideas or suggestions on how to solve this problem.

    Thank you
    Erick

    Hello
    Change in the report query, check it out.

    In a Word, changed APEX_ITEM. TEXT to APEX_ITEM. DISPLAY_AND_SAVE for the DEPTNO column.

    See you soon,.

  • update to column values (false) in a copy of the same table with the correct values

    Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.

    My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:


    Update mnt.workorders
    Set approvalstat = (select b.approvalstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)
    where exists (select *)
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)

    It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.

    Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:

    Update (select a.comappstat, b.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi - this is a PK column
    and a.comappstat! = b.comappstat)
    Set b.comappstat = a.comappstat

    Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:

    Update mnt.workorders_copy
    Set comappstat = (select distinct)
    a.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi
    and a.comappstat! = b.comappstat)
    where a.comappstat! = b.comappstat
    and a.workordersoi = b.workordersoi

    The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :

    ERROR on line 8:
    ORA-00904: "B". "" WORKORDERSOI ": invalid identifier

    First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)

    Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?

    I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.

    Thank you

    Hello

    First of all, after post 79, you need to know how to format your code.

    Your last request reads as follows:

    UPDATE
      mnt.workorders_copy
    SET
      comappstat =
      (
        SELECT DISTINCT
          a.comappstat
        FROM
          mnt.workorders a
        , mnt.workorders_copy b
        WHERE
          a.workordersoi    = b.workordersoi
          AND a.comappstat != b.comappstat
      )
    WHERE
      a.comappstat      != b.comappstat
      AND a.workordersoi = b.workordersoi
    

    This will not work for several reasons:
    The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
    There is no link between the mnt.workorders_copy and the the update and the request of void.

    If you do this you should have something like this:

    UPDATE
      mnt.workorders     A      -- THIS IS THE TABLE YOU WANT TO UPDATE
    SET
      A.comappstat =
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B   -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    WHERE
      EXISTS
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    

    Speed is not so good that you run the query to sub for each row in mnt.workorders
    Note it is condition in where. You need other wise, you will update the unchanged to null values.

    I wouold do it like this:

    UPDATE
      (
        SELECT
          A.workordersoi
          ,A.comappstat
          ,B.comappstat           comappstat_OLD
    
        FROM
          mnt.workorders        A      -- THIS IS THE TABLE YOU WANT TO UPDATE
          ,mnt.workorders_copy  B      -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
    
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      ) C
    
    SET
      C.comappstat = comappstat_OLD
    ;
    

    This way you can test the subquery first and know exectly what will be updated.
    This was not a sub query that is executed for each line preformance should be better.

    Kind regards

    Peter

  • Update the value of the column based on another value of the column to another table

    Hi all

    I have something very confused me and need your help.

    Having two tables A and B.

    Table A have 2 column (+ id + and desc1)

    Table B have column 2 also (+ transnum + and desc2)

    Now, I want to update the column desc2 of table B identical desc1 of table was where transnum of Table B same as the id of the table has.

    I use this SQL

    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1

    but this error occurs

    Error from line 5 in order:
    update of a2 set a2.desc2 = a1.desc1 of a2 on a2.transnum = a1.id inner join a1
    Error in the command line: 5 column: 35
    Error report:
    SQL error: ORA-00933: SQL not correctly completed command
    * 00933. 00000 - "command not properly ended SQL."
    * Question: *.

    * Action. *

    Hope someone can help me. TQ for help...
    SQL> create table a1 (id number(2),des varchar2(10));
    
    Table created.
    
    SQL> create table b1 (transnum number(2),des varchar2(10));
    
    Table created.
    
    SQL> insert into a1 values (1,'maran');
    
    1 row created.
    
    SQL> insert into b1 values (1,'ram');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> update b1 set des=(select des from a1 where b1.transnum=a1.id);
    
    1 row updated.
    
    SQL> select * from b1;
    
      TRANSNUM DES
    ---------- ----------
             1 maran
    
  • update of column with another column with in the same table

    Hello
    We are using oracle 10g,
    I have a table with two columns i a s number one other data type is varchar2, varchar2 column contains
    numAriques and data type character I want to move only numAriques to the numeric data type field data, please kindly give answer

    Thanks and greetings
    tmadugula

    You are not providing any version of the database, sample data or table desc, but anyway:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:3083286970877 #49518312679214

    Something like:

    create or replace function is_num
    (p_str in varchar2)
    return number
    as
    begin
      return to_number(p_str);
    exception
      when others then return null;
    end;
    

    Which translates into:

    MHO%xe> select * from bla;
    
    MY_VA  MY_NUMBER
    ----- ----------
    AAAAA
    BBBBB
    11111
    22222
    CCCCC
    33333
    
    6 rijen zijn geselecteerd.
    
    Verstreken: 00:00:01.32
    MHO%xe> desc bla
     Naam                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     MY_VARCHAR                                         VARCHAR2(5)
     MY_NUMBER                                          NUMBER(5)
    
    MHO%xe> select * from bla where is_num(my_varchar) is not null;
    
    MY_VA  MY_NUMBER
    ----- ----------
    11111
    22222
    33333
    
    Verstreken: 00:00:01.73
    MHO%xe> update bla
      2  set my_number  = is_num(my_varchar)
      3  where is_num(my_varchar) is not null;
    
    3 rijen zijn bijgewerkt.
    
    Verstreken: 00:00:00.51
    MHO%xe> select * from bla;
    
    MY_VA  MY_NUMBER
    ----- ----------
    AAAAA
    BBBBB
    11111      11111
    22222      22222
    CCCCC
    33333      33333
    
    6 rijen zijn geselecteerd.
    

Maybe you are looking for

  • Can not update the settings on the Airport Express

    Currently have a facility - two extremes and an Express network.  I for the life of me can't update the Express settings. I always get an error message but I can update the settings on the two extremes very well. I can make changes to the Express wit

  • Why my youtube video does not appear on my wordpress site on firefox udesign?

    I have a site of udesign I downloaded my video to through youtube. It was working fine until I did the last update. all forums instruct all the world to use the code, but with my theme I don't even no where to put the code. I've also read about html5

  • Drive-by infection... !

    Did a Google search today and found a result that seemed fair. Clicked on the link and started reading this site, but do not click the links on the page. A box of Windows Defender (victory 10 Pro) suddenly appears in the middle of the screen saying t

  • How to paste graphics side each other in an e-mail

    When I paste two graphics in an e-mail (Windows Live Mail) the second takes its place UNDER the first. HOW can I get the second to sit next to the first?

  • BlackBerry smartphone how to change profiles...

    Hello. I receive many emails. When my curve is set to ' normal '. Then, my phone vibrates constantly with each email. If I set the curve of 'Phone' just so that I don't get notification when I get a text message... When I click on "Custom" and then "