Dynamic update of column with values derived by formula on other table.

i have 3 tables; table A,B and C
table A has two columns (id and Quantity), based on the id value, the quantity value is computed using a formula on two rows (one from table B and the other from C).
the formula is different for each id value.
but after every month the quantity value has to be updated (because tables B & C get updated monthly).
example. given id=1, quantity= select round((sum(h.col1)/sum(p.col1), 2) from B p, C h
given id=2, quantity=select round((sum(col1)/sum(col3)), 2) from C
so for every id the quantity is derived by a different formula, but the quantity value has to be recomputed every month.
need help.

1. update table a
quantity = decode (id,1, <formul1>, id,2 , formula 2...)
2. if you wanto schedule this as monthly task
use dbms_job.submit
send the above query to "What" parameter.

Similar Messages

  • Update a column with value of column of other table

    Hi,
    I am looking for an update statement for the following scenario
    With following 2 tables
    TABLE1 (Primary A, B)
    TABLE2 (Secondary C , D).
    C Column is not unique.
    Please provide me an update statement to update TABLE1.B with TABLE2.D where TABLE1. A = TABLE2.C
    Please note that TABLE2.C is not unique.
    Please let me know whether this satement is correct.
    UPDATE TABLE1
    SET B = (SELECT DISTINCT D FROM TABLE 2 WHERE A=C )
    Thanks
    Alla Kishore

    UPDATE TABLE1 T1
    SET T1.B = (SELECT DISTINCT D FROM TABLE2 T2 WHERE T2.C=T1.A )

  • Update A Column with value of Column in the next Row

    Hi All,
    I have a table which is like this
    ID NUMBER,
    SUB_ID NUMBER,
    STARTDATE DATE.
    The Value is say for example like this:
    ID     SUB_ID     StartDate
    1     1     1-JAN-09
    1     2     20-FEB-09
    1     3     1-MAR-09
    2     1     10-JAN-09
    2     4     10-APR-09
    2     3     1-MAR-09
    2     2     2-FEB-09
    I have to add a new column END DATE in the table and populate a value which is One Day less than the value of
    start Date for next row. I have to order by ID and SubID and so that colum looks like this.
    ID     SUB_ID     StartDate          END DATE
    1     1     1-JAN-09          19-FEB-09
    1     2     20-FEB-09          28-FEB-09
    1     3     1-MAR-09          DEFAULT-END DATE
    2     1     10-JAN-09          1-FEB-09
    2     2     2-FEB-09          8-Mar-09
    2     3     9-MAR-09          9-APR-09     
    2     4     10-APR-09          DEFAULT END DATE
    Can this be achieved using a single update query or I have ot write a Procedure ...any help will be appreicaited

    or
    merge into test
    using (select rowid rid
                , id
                , sub_id
                , startdate
                , lead (startdate) over (order by id, sub_id) - 1 ed
           from test) x
    on (x.rid = test.rowid)
    when matched then
       update set end_date = x.ed
    ;

  • UPDATE value in column with value in SAME TABLE

    Hi all,
    Here's my issue...
    I have a table which records all incidents for a person.
    The table looks something like this:
    tbl_connect(person_Id NUMBer,
    OLD_ID VARCHAR2(24),
    CASE_NUMBER     VARCHAR2(10),
    CASE_TYPE     VARCHAR2(10),
    PERSON_ROLE     VARCHAR2(30),
    INCIDENT_TYPE     VARCHAR2(40));
    The table is populated from a source table with all fields except person_id. Person_id is a sequence number that gets generated if the person comitting the incident is a NEW PERSON to our system. OLD_Id is the unique identifier between the source table and tbl_connect to identify a person.
    The problem: If an existing person commits a new incident, a new record will be inserted into tbl_connect without PERSON_ID. Since the person already is in the database the person_id already exists in tbl_connect for that person. I now need to UPDATE person_id column with the person_id that already exists for this person. How can i achieve this.
    Ive been trying all sorts of update queries but nothing seems to work. ANy help will be appreciated. Thanks in advance.

    Frank,
    Thanks for the speedy reply. Here is a sample table.
    I know it's a bit confusing. The data that is being dumped into this table is information from a old system. The OLD_ID is in here because it is the relationship between this table and the old table. PERSON_ID is new to this system to identify a person uniquely. That is why i need them both in this table for right now.
    So say my tbl_connect got populated with new info from the old table. As you can see, old_id=567A has comitted another incident. Since he already exists in tbl_connect, now i need to update person_id with the value of 1. Does that make sense now????? If old_id did not exist, all i would do is insert a new row and set person_id to the next sequence number.
    TBL_CONNECT
    PERSON_ID OLD_ID      CASE_NUMBER CASE_TYPE          
    1     567A     12345          IR          
    1     567A     15236          MV
         567A     98547          IR<--newly inserted record of same person

  • How to update a column with default in a tabular form.

    We have a tabular form that has a submit button that does a multi row update. We would like to update a column with a defaut like APP_USER = updated user when the row is updated. Is this possible and how?

    used lovs and conditions.

  • Update trigger fails with value too large for column error on timestamp

    Hello there,
    I've got a problem with several update triggers. I've several triggers monitoring a set of tables.
    Upon each update the updated data is compared with the current values in the table columns.
    If different values are detected the update timestamp is set with the current_timestamp. That
    way we have a timestamp that reflects real changes in relevant data. I attached an example for
    that kind of trigger below. The triggers on each monitored table only differ in the columns that
    are compared.
    CREATE OR REPLACE TRIGGER T_ava01_obj_cont
    BEFORE UPDATE on ava01_obj_cont
    FOR EACH ROW
    DECLARE
      v_changed  boolean := false;
    BEGIN
      IF NOT v_changed THEN
        v_changed := (:old.cr_adv_id IS NULL AND :new.cr_adv_id IS NOT NULL) OR
                     (:old.cr_adv_id IS NOT NULL AND :new.cr_adv_id IS NULL)OR
                     (:old.cr_adv_id IS NOT NULL AND :new.cr_adv_id IS NOT NULL AND :old.cr_adv_id != :new.cr_adv_id);
      END IF;
      IF NOT v_changed THEN
        v_changed := (:old.is_euzins_relevant IS NULL AND :new.is_euzins_relevant IS NOT NULL) OR
                     (:old.is_euzins_relevant IS NOT NULL AND :new.is_euzins_relevant IS NULL)OR
                     (:old.is_euzins_relevant IS NOT NULL AND :new.is_euzins_relevant IS NOT NULL AND :old.is_euzins_relevant != :new.is_euzins_relevant);
      END IF;
    [.. more values being compared ..]
        IF v_changed THEN
        :new.update_ts := current_timestamp;
      END IF;
    END T_ava01_obj_cont;Really relevant is the statement
    :new.update_ts := current_timestamp;So far so good. The problem is, it works the most of time. Only sometimes it fails with the following error:
    SQL state [72000]; error code [12899]; ORA-12899: value too large for column "LGT_CLASS_AVALOQ"."AVA01_OBJ_CONT"."UPDATE_TS"
    (actual: 28, maximum: 11)
    I can't see how the value systimestamp or current_timestamp (I tried both) should be too large for
    a column defined as TIMESTAMP(6). We've got tables where more updates occur then elsewhere.
    Thats where the most of the errors pop up. Other tables with fewer updates show errors only
    sporadicly or even never. I can't see a kind of error pattern. It's like that every 10.000th update
    or less failes.
    I was desperate enough to try some language dependend transformation like
    IF v_changed THEN
        l_update_date := systimestamp || '';
        select value into l_timestamp_format from nls_database_parameters where parameter = 'NLS_TIMESTAMP_TZ_FORMAT';
        :new.update_ts := to_timestamp_tz(l_update_date, l_timestamp_format);
    END IF;to be sure the format is right. It didn't change a thing.
    We are using Oracle Version 10.2.0.4.0 Production.
    Did anyone encounter that kind of behaviour and solve it? I'm now pretty certain that it has to
    be an oracle bug. What is the forum's opinion on that? Would you suggest to file a bug report?
    Thanks in advance for your help.
    Kind regards
    Jan

    Could you please edit your post and use formatting and tags.  This is pretty much unreadable and the forum boogered up some of your code.
    Instructions are here: http://forums.oracle.com/forums/help.jspa                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to update a column with different values but all other row values r sam

    Hi,
    I have a table like this.
    Col1 col2 col3 col4
    10 20 30
    10 20 30
    10 20 30
    i need to update col4 with different values coming from other table like this
    Col1 col2 col3 col4
    10 20 30 xxxx
    10 20 30 yyyy
    10 20 30 zzzz
    how can i update the table. pls let me know how to use the where condition in the update stmt.
    thanks,
    jay
    Edited by: user2558790 on Nov 20, 2009 12:26 PM

    what is the logic for this kind of update...????
    Greetings,
    Sim

  • UPDATE multiple columns with conditional SET parameters

    I have a procedure that updates multiple columns of a table using the procedure's parameter. Is it possible to have one update statement with conditional SET parameter?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;Is it possible to replace multiple IFs from the code to have only one UPDATE statement with condition that update the column only if the passed parameter is not null? In real scenario I have more than 3 columns and I don't want to write many IF blocks.
    Please help Gurus!!
    Edited by: Kuul13 on Sep 18, 2009 1:26 PM

    Hi,
    You certainly don't want to issue separate UPDATE statements for every column; that will be really inefficent.
    SQL has several ways to implement IF-THEN-ELSE logic. CASE is the most versatile, but NVL will do everything you need for this job. You can use one of those to set a column to itself (and therefore not really update that column) when appropriate.
    For example:
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM   IN       NUMBER,
      pOED          IN   DATE,
      pTERM          IN   NUMBER,
      pTRANS_CD  IN       CHAR
    AS
    BEGIN
         UPDATE  temp
         SET     oed      = NVL (poed,       oed)
         ,     term      = NVL (pterm,       term)
         ,     trans_cd = NVL (ptrans_cd, trans_cd)
         WHERE     pol_num      = ppol_num;
      COMMIT;     -- Maybe
    END    tmp_proc;"EXCEPTION WHEN OTHERS THEN NULL" is almost always a bad idea. If there's an error, don't you want to know about it? Shouldn't you at least log a message in a warnings table or something?
    Think careflully about whether or not you want to COMMIT every time you call this procedure.
    Just as it's inefficient to issue a separate UPDATE statement for every column, it's also inefficient to issue a separate UPDATE statement for every row. If efficiency is important, it should be possible to UPDATE several rows in a single UPDATE statement, using NVL (or CASE, or COALESCE, or NULLIF, or NVL2, or ...).
    This was a very well-written question! Thanks for providing the CREATE TABLE and INSERT statements, and such a clear explanation.

  • Update multiple columns with single update statement..

    HI all,
    i am reading the columns value from different table but i want to update it with signle update statement..
    such as how to update multiple columns (50 columns) of table with single update statement .. is there any sql statement available i know it how to do with pl/sql..

    As I understood, may be this. Here i am updating ename,sal, comm columns all at once.
    SQL> select * from emp where empno=7369;
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17/12/1980 12:00:00        800                    20
    SQL> UPDATE emp
      2     SET ename = lower (ename),
      3         sal = sal + 1000,
      4         comm = 100
      5   WHERE empno = 7369;
    1 row updated.
    SQL> select * from emp where empno=7369;
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7369 smith      CLERK           7902 17/12/1980 12:00:00       1800        100         20
    SQL> UPDATE emp
      2     SET ename = (SELECT 'ABCD' FROM DUAL),
      3         sal = (SELECT 1000 FROM DUAL),
      4         comm = (SELECT 100 FROM DUAL)
      5   WHERE empno = 7369;
    1 row updated.

  • Update a column with info from columnA, and if not in columnA, then columnB

    I have a situation where I have to update a columnC with information stored one of 2 ways. It is stored one way in ColumnA, and another way in columnB. I must check the string if it is in columnA first, and if it is, that value will go in columnC to be updated. If it is not, I must go on to columnB and find it there. It will be in one of the 2 columns but I must use the way it is stored in these columns to store in my columnC to be updated. The data is basically turned around (not reversed letter for letter, though) in the 2 columns and must be stored the way it is found in columnA or columnB. Any ideas?

    It's that simple? It will look in both columns this way? Now, I actually mentioned UPDATE when I meant INSERT, so I am doing this in a VALUES clause? Will I just use the phrase 'nvl(A, B);'?

  • How to Loop through another list and update a column with SharePoint Designer 2013 Workflow

    Hi,
    I am trying to get my head around the new 2013 Workflow Engine and SharePoint Designer 2013 Workflow Text-Based Designer.
    I have two lists.
    List A has 2 columns: Title, Completed (Yes/No)
    List B has 3 columns: Title, LookupListATitle, Completed (Yes/No)
    All the 2013 Workflow components have been installed and configured and I am selecting the 2013 Workflow option in SPD
    I am trying to set off a 2013 Workflow when an item in List A is edited to Loop through List B and select items where the LookupListATitle column's value is equal to the Title value of the current item, and set the value of the Completed column for those
    items in ListB to "Yes".
    I have the Workflow configured like this:
    Stage: Stage 1
    IF Current Item:Completed equals Yes
    Loop: 1
    The contents of this loop will run repeatedly while: ListB:LookupListATitle equals Current Item: Title
    Update item in ListB. 
    (The dialog options for the update item action as follows:
    List: ListB
    Field: Completed, Value: Yes
    In the Find the List Item section
    Field: LookupListATitle
    Value: Current Item: Title)
    Transition to stage
    Go to End of Workflow
    When I update an item in ListA and set its Completed column to Yes, I would expect the Workflow to find all the items in List B where the Lookup column is equal to ListA's Title (there are 2) and update their Completed column to Yes. But it doesn't work.
    When I look at the Workflow Status it says the Internal Status is "Canceled" and the information pop up has the following alien language (and may be truncated):
    RequestorId: 95f03b62-8956-ac14-c5cf-dc98c89c589c. Details: System.ArgumentException: Invalid JSON primitive: Item001. Parameter name: value at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.ConvertStringToJsonNumber(String value) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.ReadPrimitive(String
    type, XmlDictionaryReader jsonReader) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.JXMLToJsonValue(XmlDictionaryReader jsonReader) at Microsoft.Workflow.Common.Json.JXmlToJsonValueConverter.JXMLToJsonValue(Stream jsonStream, Byte[] jsonBytes)
    at Microsoft.Activities.DynamicValue.ParseJson(String json) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
    executor, BookmarkManager bookmarkManager, Location resultLocation)
    Unfortunately I don't have access to the server, logs etc.
    I would love to find some tutorials, or any books on SharePoint Designer 2013 in general and Workflows in particular but my searches haven't turned up much so far apart from a pre-release Beginning SharePoint Workflows which is in its very early stages and
    not much help yet.
    Can anyone give me some guidance on how to set up While Loops to iterate through a related list using SharePoint Designer 2013?
    Mark

    Hi,
    I understand that you wanted to update the items in the other list (Participants) where the Course equals the Current Item.
    You need to use “Call HTTP Web Service" action and “Build Dictionary" action to get the Maxid and then loop Participants to update the items.
    You can follow the steps as below to achieve what you want:
    Create a custom list named Courses, add columns: Title(Single line of text), Course ID(Single line of text), Course Finalised (Yes/No).
    Create a custom list named Participants, add columns: Title(Single line of text), Course(Lookup), CourseFinalised (Yes/No).
    Create workflow associated to Courses, start the workflow automatically when an item is created or changed.
    Add conditions and actions:
    The HTTP URL is set to
    https://sitename/_api/web/lists/GetByTitle('listname')/items?$orderby=Id%20desc and the HTTP method is set to “GET”. Then the list will be order by Id and desc.
    Then if Course Finalised is equal to Yes, the CourseFinalised  of the associated items in Participants will be updated to Yes.
    More information:
    http://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to update old instances with values

    Hi,
    i am using albpm 5.7 version.
    i have a requirement i need to update the oldinstances with updated data.
    suppose i have added new external variable to process how it will update the old instances.
    plz suggest how to solve this problem.
    Regards,
    Srinivas.

    Hi,
    The standard behaviour is that new instances of the process will use the most recent version of the process that has been deployed to the database. This allows you to deploy new versions of the processes without impacting on processes which are already in progress.
    When the workflow engine determines what activity to run next in the process, the engine checks what the start date of the process instance was, so that it can check what version of the process was active at that time. If you update the start date for each running process, so that it reflects the date that you saved the most recent version of the flow, then the workflow engine will use the latest version instead of the version that it was running.
    This is not supported. I would never suggest that you do this in a production environment - it does not make sense to be making frequent changes to the process in a production environment, since there is no supported mechanism for forcing existing flows to use the new definition. The engine is designed specifically to run the same version of the process for the duration of the process instance - what you want to do is to blow this out of the water completely. If you do change this, then all timing that is recorded against the activities becomes useless, and the other impact on the workflow process us something that you would need to consider incredibly carefully before deciding whether you want to take the risk.
    HTH,
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://thoughts.workflowfaq.com ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • LINQ: Update a column with auto increment value

    Hi All,
    Greetings.
    I am very new to C# (though with lot of experience in VC++). Now a days, I am engaged in a C# project where I need to deal with ADO.NET DataTable and related classes. I am stuck up in a scenario as follows:
    I have a data table (of DataTable type) pre-populated with many rows (50000+), parsed from a log file. Now I need to add a column that will be holding index number for each records; eg. 1, 2, 3......
    I have tried to add the auto-incremented column dynamically, with seed = 0 and increment = 1, but it is not working.
    Is there any LINQ query that I can run to update the DataTable at once? Or foreach loop per DataRow is the only option here?
    I appreciate any quick suggestion on this.
    Thanks in advance.
    Sanjoy Jana.

    You should add the auto increment column to the DataTable before you pouplate it with the other data:
    //1. Create a datatable
    DataTable dt = new DataTable();
    //2. add the autoincrement column:
    DataColumn column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.AutoIncrement = true;
    column.AutoIncrementStep = 1;
    column.AutoIncrementSeed = 1;
    //3. Fill the dataTable using an SqlDataAdapter or whatever
    dt.Columns.Add(new DataColumn("name"));
    dt.Rows.Add("1");
    dt.Rows.Add("2");
    dt.Rows.Add("3");
    dt.Rows.Add("4");
    Then you don't have to add the "auto incremented" values yourself in some kind of a loop (using for example LINQ or foreach).
    If you want to know how to poplulate the DataTable from a database query using an adapter, please refer to the following page:
    http://www.dotnetperls.com/sqldataadapter
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

  • Finding Updated Columns with Values in Rows

    Hello,
    I have a one requierment as below.
    if I have Table ITEM with Below records
    ParcelID 
    ItemCode
    CurrentLocation
    Destination
    UpdatingTime
    1010         
    GLS
    ABC
    XYZ
    01-12-14
    1015         
    PHM
    SSS
    ZZZ
    01-12-14
    If any of the column value is updated it will replicate to ITEMUPDATE table with old row and new row as well.
    Suppose for ParcelID 1010 CurrentLocation Changed from ABC to CDE it will store in ITEMUPDATE table with both records
    old and new and if ParcelID 1015 CurrentLocation Changed from SSS to KKK it will also store as below.
    Now ITEMUPDATE table will have all records old as well as new rows as below.
    ParcelID
    ItemCode
    CurrentLocation
    Destination
    UpdatingTime
    1010      
    GLS
    ABC
    XYZ
    01-12-14
    1010      
    GLS
    CDE
    XYZ
    02-12-14
    1015      
    PHM
    SSS
    ZZZ
    01-12-14
    1015      
    PHM
    KKK
    ZZZ
    01-12-14
    Like this any column can update not only CurrentLocation.
    Now the requirement is I want to know which columns is updated and what is the new value.
    Some what results need to look like below.
    ParcelID
    Old_CurrentLocation
    New_CurrentLocation
    1010     
    ABC
    CDE
    1015     
    SSS
    KKK
    Please Anyone Can help me on this .
    Thank You,
    Avis

    Hello Avis,
    You need to store date and time in 'UpdatingTime' column in both ITEM and ITEMUPDATE tables.
    If you store only date, you will not get desired results as there may be multiple records for a 'ParcelID' in the same date in ITEMUPDATE table. It is difficult to get the latest record from multiple records with same dates for a 'ParcelID' from ITEMUPDATE.
    Alternatively you can create a surrogate key   , like 'ItemUpdateID', in ITEMUPDATE from which we can get the latest record for a 'ParcelID'. The surrogate key can be a integer identity column so that automatically incremented and updated for each insert
    in ITEMUPDATE. Then it is easy to get latest UpdatingTime for a ParcelID from ITEMUPDATE  table.
    If the table design and data is something as below:
    ITEM table
    ParcelID    ItemCode    CurrentLocation    Destination    UpdatingTime
    1010         GLS                ABC                     XYZ              
    2014-01-12
    1011         MMX               ABD                     XVB  
                2014-01-12
    1015        PHM                SSS                     ZZZ               
    2014-01-12
    ITEMUPDATE table
    ItemUpdateID    ParcelID    ItemCode    CurrentLocation    Destination    UpdatingTime
    1                         1010         GLS                
    ABC                     XYZ          2014-01-12
    2                         1015         PHM                SSS             
            ZZZ          2014-01-12
    3                         1015         PHM               
    KKK                      ZZZ          2014-02-12
    4                         1010         GLS                
    CDE                      XYZ          2014-02-12
    5                         1011         MMX               
    ABD                      YYY           2014-01-12
    Here 'ItemUpdateID' is identity column.
    The SELECT query can be written as below:
    SELECT A.ParcelID, A.ItemCode,
    B.CurrentLocation 'New_Location',
    ISNULL((SELECT CurrentLocation FROM ItemUpdate WHERE ItemUpdateID = (SELECT MAX(D.ItemUpdateID)
    FROM ItemUpdate D WHERE D.ItemUpdateID < B.ItemUpdateID AND D.ParcelID = B.ParcelID)), A.CurrentLocation) 'Old_Location'
    FROM Item A
    LEFT JOIN ItemUpdate B On B.ParcelID = A.ParcelID
    AND B.ItemUpdateID = (SELECT MAX(ItemUpdateID) FROM ItemUpdate C WHERE C.ParcelID = B.ParcelID)
    The result will be as follows:
    ParcelID    ItemCode    New_Location    Old_Location
    1010          GLS              CDE                   ABC
    1011          MMX             ABD                    ABD
    1015          PHM             KKK                     SSS

  • Filling a column with value from other columns

    Hello all!
    Suppose i have the following table:
    TableA(col_one int, col_two int, result int);I want to insert value to col_one and col_two, and result will be filled with the multiplication product of col_one and col_two.
    ok firstly i know this is very redundant way of storing data and generally should not be used, but one case when this might come in handy is when we want to store a total payment amount of product price and quantity. this can be useful since product price can change overtime and we need to record the data as the transaction happens to avoid change in total payment over time (as the price drops or rises).
    now with the problem:
    I tried this in mysql and it works:
    INSERT INTO TableA (col_one, col_two, result) VALUES (30,  20, col_one * col_two);but not in oracle, which output the following error:
    >
    ora 00984 column not allowed here
    any idea on how to do it in oracle?
    thank you very much :)
    ps, thank you for the fast replies on my previous topic.

    If the insert is done inside PL/SQL you can return the primary key for the row (assuming the table has a primary key?!?) and then update based on that key, but this still introduces two statements where a single statement can suffice.
    Why are you thinking so complicated? ;-)
    If it is done in PL/SQL the you can do this:
    create procedure addRow(p_value1 number,p_value2 number) is
    p_result number;
    begin
    p_result:=p_value1*p_value2;
    insert into table1 (col_one,col_two,result) values(p_value1,p_value2,p_result);
    commit;
    end;If you want to do this automatically when someone inserts a row (without providing the result) you have to use an insert trigger.
    Dim

Maybe you are looking for

  • Mini DVI to HMDI TV

    Hi, I have this MacBook Pro 13 inch mid 2010 model. I want to connect to my HDMI tv which has 2 HDMI inputs and VGA, and Audio. someone said I could connect with a mini DVI to HDMI adapter but it might not have audio (which from what I can tell from

  • Connection to Remote Desktop is keep dropping

    Hello everybody, I use my laptop to remote in to my office work station. So, what I do is I go through a portal, which authenticates me to login to my office work station. When I start working on it, my remote connection drops for every 3 (approx)  m

  • Please help me tuning this query...

    Hi all, Can any body suggest some changes (synthatic) so that it can improve its performance... taking too much time... This is a query used in oracle report... SELECT  distinct cc.seg1,cc.seg2,cc.seg3,cc.seg4,cc.seg5,cc.seg6,cc.seg7,cc.seg8,cc.code_

  • Web Services in CF10, components not found - Java vendor problem?

    Is anyone having problems invoking web services in CF10, IIS 7, Java Oracle?  We recently upgraded, and the web services are now returning the following error that the component can't be found: The web service operation caused an invocation exception

  • Finding Non Standard Service Accounts from all AD Computers / Servers

    Hi Guys, I am trying to get the list of all Service Accounts, which are non-standard from an AD domain network using PowerShell. The code is provided below. But it is not working (Through individual cmdlet through console, working fine.) Tried withou