Update table based on ID reference comparing each column and value

Hi,
Through UI user can update any information and click save. In backend i will be receiving only ID as reference . Based on the ID value i should update multiple tables wherever i have the reference tables. Here i will not get the values or column name updated.
I just get a ID to find which row is updated.
I should do a comparision now. 
I have a history table where i get the row before updation. and i get a row after updation from current data i.e. from ssdb_Railroad[This will be updated by java after updation we will get the ID inorder to update remaining tables]. Now i need to compare
both the table column values and know which column is updated and after getting the value i should update reference tables.
Below is the structure for comparision table , History table and Main table.
Create table Comparision_History (
 ID   int IDENTITY(1,1) PRIMARY KEY,
 InsertUser_UpdateUser varchar(50),
 Old_ColVal  varchar(100),
 New_ColVal  varchar(100),
 TableName   varchar(100),
 [Action]     varchar(50),
 InsertDate_UpdateDate Datetime NOT NULL DEFAULT getdate()
CREATE TABLE SSDB_Railroad_History (
    ID         int IDENTITY PRIMARY KEY,
SCAC       varchar(4) ,
Name       varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
  varchar(50),
NOTES      varchar(1000),
[Action]   varchar(50),
InsertDate_UpdateDate  Datetime NOT NULL DEFAULT getdate(),
InsertUser_UpdateUser  varchar(50),
CREATE TABLE SSDB_Railroad (
    ID   int IDENTITY(1,1)PRIMARY KEY,
SCAC varchar(4) UNIQUE,
Name varchar(50) NOT NULL,
RailroadID int NOT NULL UNIQUE,
RC2Key
varchar(50),
InsertDate Datetime NOT NULL DEFAULT getdate(),
UpdateDate Datetime,
InsertUser varchar(50),
UpdateUser varchar(50)
Here SSDB_Railroad table and History table needs to be compared and get a updated value and it should be inserted in a comparision table. as well as it should be updated in reference tables.
Please help me with the code.
Thanks in Advance
Deepa

Hi Deepa_Deepu,
According to your description, personally, the merge function can meet your requirements. Usually, we can synchronize two tables by updating or inserting rows in a target table based on differences found in the source tables. Just as your description, when
the value of ID and InsertDate_UpdateDate in the source table matches a value, update them in the target table. When the values does not match, the source row is inserted into the target table.
For more information, see: using MERGE to perform UPDATE and INSERT operations on a target table by using a derived source table.
http://msdn.microsoft.com/zh-cn/library/bb510625.aspx
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support

Similar Messages

  • Update Query based on a reference to another table

    I have a table TableA which contains two columns PKey, EmployeeID.
    I have anohter table TableB which contains FName, LName, City, State and a reference key TableA_PKey referenced to PKey in TableA.
    I want to update TableB and set the values of TableB.State = 'CA' where TableA.EmployeeID in (111, 222, 333)
    How do I write this update query? thanks

    Hi,
    This does what you requested:
    UPDATE  tableb
    SET     state     = 'CA'
    WHERE     tablea_pkey  IN (
                            SELECT  pkey
                       FROM    tablea
                       WHERE   employeeid     IN (111, 222, 333)
    ;Whenever you have a problem, it helps if you post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and the results you want from that data.
    In the case of DML problems (including UPDATE), the sample data should show what all the tables are like before the DML, and the results will be the contents of the changed table after the DML.
    Always say what version of Oracle you're using.

  • Compare 45 columns and update one table col

    I am using Oracle 9i database.I need to compare each record between two tables
    and update the one of table column (what records are updated)
    CURSOR cur1 is select t1., t2. from t1, t2 where t1.primarykey = t2.primarykey
    FOR rec1 IN cur1
    LOOP
    IF rec1.t1_col_1<>rec1.t2_col_1
    then
    update t1
    set col_t1.rem="MOdified",t.col_1=rec1.t2_col_1
    where t1.primerykey=rec1.primarykey
    END IF;
    IF rec1.t1_col_2<>rec1.t2_col_2
    then
    update t1
    set col_t1.rem="MOdified",t.col_2=rec1.t2_col_2
    where t1.primerykey=rec1.primarykey
    END IF;
    ..........45 if else conditions
    END LOOP;
    I have 1 million records to compare and 45 columns to compare, how do I increase performance.
    Currently it takes about 5hrs for the cursor to go through this if -else comparison.
    Thanks and Regards
    Swayamprakash.Chiluveru

    Hi Swayamprakash,
    Few basics first.
    1. DML SQL's perform better than PL/SQL. Sounds great but Oracle then need to hop between SQL and PL/SQL engine for every record in the cursor causing THRASHING. This is an old concept, reference of which can be found in Operating Systems.
    With Bulk Collect option, this could be minimized to a large extent, but causes a large amount of Undo being generated. This is another pitfall of using Bulk Collect. Morever, when you expect more percentage of records to be updated, it is advisable that the indices (if any) must be disabled. They can be rebuild afterwards causing very minimal amount of Undo. Performance gain is expected here.
    Now a query that you need to clarify:
    1. One million records to be updated on a diurnal basis - An OLTP database might need this functionality which is better handled by a screen driven interface rather than a SQL/Procedure running in background.
    An OLAP database must simply ignore such requirements for they are meant to be history archives.
    Suggestion:
    Merge - Seems to be the only optimal solution at the moment for the exact requirements are unclear. Already, somone has suggested this.
    Oracle Developers, DBA's must setp out from technicalities and turn towards functionality.
    Kind regards,
    Abhijit

  • Update table based on collection

    Hello friends,
    I have two tables:
    1- PHOTOS (img_id number (5,0),Product_id number (5,0), Content Blob ....)
    2- PRODUCTS (Product_id number (5,0), product_type .... )
    each product has 1 to 6 images.
    I need to watermark the uploaded images in the memory then update the original images for the watermarked images.
    I used this code, but the problem is how to update the images in the photos table based on the product_id ???
    DECLARE
    type source_col is table of blob index by pls_integer ;
    V_source source_col;
    cursor c1 is select CONTENT from photos where Product_id = :P22_Product_id;
    counter number :=1;
    added_image       BLOB;
    prop ordsys.ord_str_list;
      logging VARCHAR2(2000);
    begin
    --- Here we choose a pattern for watermarking from a table called WATERMARK_PHOTOS
    select img INTO added_image FROM WATERMARK_PHOTOS WHERE N = 1;
    for rec in c1 loop
    V_source(counter) := rec.CONTENT;
    ORDSYS.ORDImage.process(V_source(counter), 'fixedScale=900 500');
    ORDSYS.ORDImage.applyWatermark(V_source(counter), added_image, V_source(counter), logging, prop);
    --- The problem in the following statement: How to update the images
    UPDATE photos SET CONTENT = V_source(counter) where Product_id = :P22_Product_id;
    Counter := counter + 1 ;
    end loop;
    COMMIT;
    EXCEPTION
       WHEN OTHERS THEN
       RAISE;
    END;

    Thanks Sybrand,
    I am using Oracle 11g R2 Standard One edition.
    the DDL of the photos table is
    ID     NUMBER     5     0     
    product_id     NUMBER     5     0     
    FILENAME     VARCHAR2     100          
    MIMTYPE     VARCHAR2     250          
    FILESIZE     VARCHAR2     20          
    CONTENT     BLOB          in my application I do not know the image id in advance, but i know the id of the product of which I want to edit the images. So:
    in the following procedure :p22_product_id is the value of of the primary key of Products table.
    I followed your tips, and it worked out. Can you please check and assure that it is OK :
    DECLARE
    type source_col is table of blob index by pls_integer ;
    V_source source_col;
    type id_col is table of number index by pls_integer ;
    V_id id_col;
    added_image       BLOB;
    prop ordsys.ord_str_list;
      logging VARCHAR2(2000);
    begin
    select content bulk collect into V_source from photos where product_id = :p22_product_id order by id ;
    select id bulk collect into V_id from photos where product_id = :p22_product_id order by id ;
    SELECT img INTO added_image FROM timg WHERE N = 1;
    for i in V_source.first .. V_source.last
    loop
    ORDSYS.ORDImage.process(V_source(i), 'fixedScale=900 500');
    ORDSYS.ORDImage.applyWatermark(V_source(i), added_image, V_source(i), logging, prop);
    UPDATE photos SET CONTENT = V_source(i) where id = V_id(i);
    end loop;
    COMMIT;
    EXCEPTION
       WHEN OTHERS THEN
       RAISE;
    END;Best Regards,
    Fateh

  • Error updating tables based on schema

    Hello,
    I'm trying to update a table based on the next schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:element name="HILO" xdb:SQLType="HILO_TYPE" xdb:defaultTable="HILO_TABLE">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="MENSAJE" maxOccurs="unbounded" xdb:SQLType="MENSAJE_TYPE" xdb:maintainOrder="false">
                             <xs:complexType>
                                  <xs:sequence>
                                       <xs:element name="FECHA" type="xs:date" xdb:SQLType="DATE"/>
                                       <xs:element name="TITULO" xdb:SQLType="VARCHAR2">
                                            <xs:simpleType>
                                                 <xs:restriction base="xs:string">
                                                      <xs:maxLength value="200"/>
                                                 </xs:restriction>
                                            </xs:simpleType>
                                       </xs:element>
                                       <xs:element name="CUERPO" type="xs:string" xdb:SQLType="VARCHAR2"/>
                                       <xs:element name="DNI_CREADO_POR" xdb:SQLType="VARCHAR2">
                                            <xs:simpleType>
                                                 <xs:restriction base="xs:string">
                                                      <xs:maxLength value="9"/>
                                                 </xs:restriction>
                                            </xs:simpleType>
                                       </xs:element>
                                       <xs:element name="ASIGNATURA" xdb:SQLType="VARCHAR2">
                                            <xs:simpleType>
                                                 <xs:restriction base="xs:string">
                                                      <xs:maxLength value="3"/>
                                                 </xs:restriction>
                                            </xs:simpleType>
                                       </xs:element>
    <xs:element name="APROBADO" xdb:SQLType="VARCHAR2">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:enumeration value="APROBADO"/>
    <xs:enumeration value="RECHAZADO"/>
    <xs:enumeration value="PENDIENTE"/>
    </xs:restriction>
    </xs:simpleType>
                                       </xs:element>
                                  </xs:sequence>
                                  <xs:attribute name="NUMERO" type="xs:int" use="required" xdb:SQLType="INTEGER"/>
                             </xs:complexType>
                        </xs:element>
                   </xs:sequence>
                   <xs:attribute name="CONTADOR" type="xs:int" use="required" xdb:SQLType="INTEGER"/>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    And the update that i'm trying to do is the next one:
    UPDATE hilo_table p
    SET value(p) =
    updatexml(value(p),'/HILO/MENSAJE/CUERPO/text()', 'Edit' )
    where existsnode(VALUE(p), 'HILO[@CONTADOR="1"]') = 1;
    ERROR en línea 1:
    ORA-01732: operación de manipulación de datos no válida en esta vista
    I have updated another tables based on schema and it works fine, any idea?

    OK this is your decision. However If you are building a production system that is important to your orgnanization as the product manager I strongly recommend that you either upgrade to a least 9.2.0.3.0 or discontinue using XML DB technology completely
    There are probably somewhere in the order of 500 serious XML DB related bugs fixed between 9.2.0.1.0 and 9.2.0.7.0, all of which have been regarded as serious enough to impossible for a customer to develop or deploy a production system. None of these will EVER be fixed or available as patches for 9.2.0.1.0.
    The way in which we store the data on the disc is different in 9.2.0.3.0, and while in theory we migrate the on disc format when you upgrade in practice I know that is has never been tested with any significant amount of data present.
    Also you really want to take the support situation into account. Image this, it's 3:00am in the morning and your production system fails due one of the bugs that have been fixed in a later release of the product. You cannot find a workaround and you call oracle support for help. They WILL say, sorry there is nothing we can do until you upgrade to 9.2.0.3.0. Now you have to upgrade in hurry and then re-test everything you have done before you can even start working on a fix.
    From a business perspective staying on 9.2.0.1.0 and continuing to use the XML DB technology makes no sense. I hope I have made this clear. If you want I will be more than happy to discuss this issue with your development managers.

  • Update table based on values from other table

    Hi,
    I am trying to update one table based on the values of another table. Since you can't use From in update statements, how do you execute this?
    For example i have to tables, Table A and Table B. I want to update a column or columns in Table A based on another value in Table B:
    So if the column in Table B was 1 then column in Table A would be Yes, if Table B was 2, then Table A would be Yes, if Table B was 3 then Table A would be N/A and so on...
    Any help would be appreciated.
    thanks,
    scott

    SQL> select * from t1;
    ID ST
    1
    2
    3
    SQL> select * from t2;
    NO
    1
    2
    3
    4
    SQL> update t1 set status=(select decode(no,1,'Y',2,'N','NA') from t2 where t1.id=t2.no);
    3 rows updated.
    SQL> select * from t1;
    ID ST
    1 Y
    2 N
    3 NA
    Daljit Singh

  • How to split data into tables based on the entries in a column?

    My problem is very similar to this thread: how to link data from one numbers sheet to another sheet, however I could get it to work the way described there. I have one big table for entering data (the first one). I would like to have a few other tables populated automatically based on the entries in one of the columns of the first table. In my example below I put everything in one sheet for clarity. The selection to the other tables is to be done on the column "fruit" in the first table. (second one is "oranges", then "apples" and then "pears" -- had to cut the width of my screenshot due to the limitations of Apple's forums).
    Here is what it would look like, just cannot figure out how to make it happen automatically.
    Tried also importing similar Excel example to Numbers, but the import did not work correctly.
    Any help will be appreciated.
    LD

    Larry,
    Here's an approach that I've used...
    In the Purchases table, Aux column, the expression is:
    =COUNTIF($A$1:A2, A) & "-"&A
    Fill Down
    This expression builds a string that identifies the item and the ocurrance of that item.
    The Date column of the Summary tables, cell a3, contains:
    =IF(ROW()-3<COUNTIF(Purchases :: $A,$A$1), LOOKUP(ROW()-2&"-"&$A$1, Purchases :: $F, Purchases :: B), "")
    Fill Across, then fill down.
    Regards,
    Jerry

  • How to select records based on Max/Min on different columns and group by

    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3
    Please help me with this.. Thanks in advance....

    Hi,
    Welcome to the forum!
    962163 wrote:
    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3It looks to me like "1 6 1" is the correct answer. You're asking for the lowest value of e, and 1 is lower than 3.
    Maybe you don't want MIN (e). Explain why you want 3 (that is, how you decided that 3 is the correct value for the last column) and someone will help you code it.
    Edited by: Frank Kulash on Sep 28, 2012 6:17 PM
    Whenever you have a problem, you should psot CREATE TABLE and INSERT statements for your sample data. That way, the people who want to help you can re-create the problem and test their ideas. It often helps to clarify the problem, too. since this is your first message, I'll do it for you:
    CREATE TABLE     table_x
    (       a     NUMBER
    ,     b     NUMBER
    ,     c     NUMBER
    ,     d     NUMBER
    ,     e     NUMBER
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 2, 1);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 4);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 3);
    COMMIT;

  • I want to compare two columns and replace any equal values with the value in a specific cell

    I want to compare the numbers in two columns and replace all matching numbers in the second columns with the corresponding value from a cell in the same row as the matching number. 

    Me too.
    Barry

  • How do I create a table of 3 data elements for each trial and have it updated instead of waiting until the end of the program?

    I am trying to record 3 pieces of data, all (software) timing in ms (in U8 integers). I managed to finally get each data in the right column but now it doesn't record anything in the table and it doesn't update the numeric indicators during the experiment like it should. I can't figure for the life of me what I did wrong. I know at least the trial part of the program works, but so far the data recording part is giving me a headache.
    Thanks
    Attachments:
    BETACRT.vi ‏241 KB

    Why it is not reporting the data is easy; fixing the program may not be. LabVIEW uses a dataflow paradigm. This means that no part of the program executes until all of its data inputs are availble. In your case the table and the array functions driving it are fed by outputs from the outer while loop. Thus no data gets to the table until the while loop has finished executing (which is at the end of your experiment). One possible approach would be to store the data in a shift register and move the table inside the loop.
    Many experienced LV programmers try to avoid or minimize the use of sequence structures and local variables to read and write to/from front panel objects. We use a state machine which is a while loop with a case structure. Queues can be u
    sed to pass data between the user interface and the data acquistion loops. This subject is too involved to be handled in a brief posting, but if you search the archives and examples you can learn more.
    Also, be aware that software timing can be problematic if you are using a desktop operating system. If the OS decides to check the net for software updates or something you could have large discrepancies in your timing. These might be rare, but there is no reliable way of detecting them. I have built several systems similar to what you seem to be trying to do and have never been successful with software timing.

  • Updating TABLEA based on values in TABLEB

    Hi: I have the two following tables. I want to write a query which updates fields in TABLE1 based on certain values in TABLE2
    1. Update SEVERITY in TABLE1 with SVRT_CD in TABLE2 for all TABLE1.INCIDENT = TABLE2.TKT_NBR
    2. Update ESCALATION in TABLE1 with ESCL_LVL in TABLE2 for all TABLE1.INCIDENT = TABLE2.TKT_NBR
    3. If the TABLE2.MNS_STATUS is 5 then set TABLE1.INCIDENTSTATUS='Acls' for all TABLE1.INCIDENT = TABLE2.TKT_NBR
    4. If the TABLE2.MNS_STATUS is 4 then set TABLE1.INCIDENTSTATUS='Bctk' for all TABLE1.INCIDENT = TABLE2.TKT_NBR
    remedy@MDS> descr TABLE1;
    USERID         NOT NULL VARCHAR2(32)
    INCIDENT       NOT NULL VARCHAR2(64)
    INCIDENTSTATUS NULL     VARCHAR2(16)
    SEVERITY       NULL     NUMBER
    ESCALATION     NULL     NUMBER
    ONSTRAINT user_pk PRIMARY KEY (USERID,INCIDENT)
    netcool@RMDSP02> describe TABLE2;
    TKT_NBR                     NULL     NUMBER(10,0)
    ESCL_LVL                    NULL     NUMBER(2,0)
    SVRT_CD                     NULL     VARCHAR2(1)
    MNS_STATUS                  NULL     NUMBER(1,0)
    CONSTRAINT tkt_pk PRIMARY KEY (TKT_NBR)I think this will do what I want in #1 and #2. Can someone confirm?
    UPDATE TABLE1
    SET (SEVERITY, ESCALATION) = (SELECT SVRT_CD,ESCL_LVL from TABLE2 where to_number(TABLE1.INCIDENT) = TABLE2.TKT_NBR)Not sure how do I do the #3 and #4.
    Thanks
    Ravi

    For point 3 and 4 use decode. and dont forget to use EXISTS in your update.
    UPDATE table1
       SET (severity,
            escalation,
            incidentstatus) = (SELECT svrt_cd,
                                escl_lvl,
                                DECODE(mns_status,5,'Acls',4,'Bctk')
                           FROM table2
                          WHERE TO_NUMBER(table1.incident) = TABLE2.TKT_NBR)
    WHERE EXISTS (SELECT NULL
                  FROM table2
                 WHERE TO_NUMBER(table1.incident) = TABLE2.TKT_NBR)        Thanks,
    Karthick.

  • Update table based on a select with a where clause

    I am trying to update a table only for records where i have a status of changed.
    Using the following code the update changes all the records putting in blank data if it is outwith the where clause.
    ideas?
    -- Update changed records
    UPDATE IP_SURVEY_ACTIVITY_REG_NO old
    SET (
    old.SLPN,
    old.SURVEY_DATE,
    old.SEQUENTIAL_REF_NUMBER,
    old.TOTAL_NUM_OF_SAMPLES,
    old.TOTAL_NUM_OF_ASSOC_SAMPLES,
    old.AIR_TESTS,
    old.REMARKS,
    old.SURVEY_DETAILS,
    old.FURTHER_SURVEY_DETAILS,
    old.GENERAL_COMMENTS) =
    (SELECT
    new.SLPN,
    new.SURVEY_DATE,
    new.SEQUENTIAL_REF_NUMBER,
    new.TOTAL_NUM_OF_SAMPLES,
    new.TOTAL_NUM_OF_ASSOC_SAMPLES,
    new.AIR_TESTS,
    new.REMARKS,
    new.SURVEY_DETAILS,
    new.FURTHER_SURVEY_DETAILS,
    new.GENERAL_COMMENTS
    FROM IP_SURVEY_ACTIVITY_REG_NO_INT new
    WHERE new.load_id = v_load_id
    AND new.status = 'CHANGED'
    AND new.sarn = old.sarn);
    cheers bjorn

    The EXISTS claue just needs to be added to your original query as a predicate on the ip_survey_activity_reg_no table. somethign like:
    UPDATE ip_survey_activity_reg_no old
    SET (old.slpn, old.survey_date, old.sequential_ref_number,
         old.total_num_of_samples, old.total_num_of_assoc_samples,
         old.air_tests, old.remarks, old.survey_details,
         old.further_survey_details, old.general_comments) =
                         (SELECT new.slpn, new.survey_date,
                                 new.sequential_ref_number,
                                 new.total_num_of_samples,
                                 new.total_num_of_assoc_samples, new.air_tests,
                                 new.remarks, new.survey_details,
                                 new.further_survey_details,new.general_comments
                          FROM ip_survey_activity_reg_no_int new
                          WHERE new.load_id = v_load_id and
                                new.status = 'CHANGED' and
                                new.sarn = old.sarn)
    WHERE EXISTS (SELECT 1 FROM ip_survey_activity_reg_no_int new
                  WHERE new.load_id = v_load_id and
                        new.status = 'CHANGED' and
                        new.sarn = old.sarn)An updateable join view is similar, except you just join the two tables. Assuming that sarn is the primary key of ip_survey_activity_reg_no_int, or is at least declared as unique in that table, then the update of the join would look something like:
    UPDATE (SELECT old.slpn oslpn, old.survey_date osurvey_date,
                   old.sequential_ref_number osequential_ref_number,
                   old.total_num_of_samples ototal_num_of_samples,
                   old.total_num_of_assoc_samples ototal_num_of_assoc_samples,
                   old.air_tests oair_tests, old.remarks oremarks,
                   old.survey_details osurvey_details,
                   old.further_survey_details ofurther_survey_details,
                   old.general_comments ogeneral_comments,
                   new.slpn nslpn, new.survey_date nsurvey_date,
                   new.sequential_ref_number nsequential_ref_number,
                   new.total_num_of_samples ntotal_num_of_samples,
                   new.total_num_of_assoc_samples ntotal_num_of_assoc_samples,
                   new.air_tests nair_tests, new.remarks nremarks,
                   new.survey_details nsurvey_details,
                   new.further_survey_details nfurther_survey_details,
                   new.general_comments ngeneral_comments
            FROM ip_survey_activity_reg_no old, ip_survey_activity_reg_no_int new
            WHERE new.sarn = old.sarn and
                  new.status = 'CHANGED' and
                  new.load_id = v_load_id)
    SET oslpn = nslpn,
        osurvey_date = nsurvey_date,
        osequential_ref_number = nsequential_ref_number,
        ototal_num_of_samples = ntotal_num_of_samples,
        ototal_num_of_assoc_samples = ntotal_num_of_assoc_samples,
        oair_tests = nair_tests,
        oremarks = nremarks,
        osurvey_details = nsurvey_details,
        ofurther_survey_details = nfurther_survey_details,
        ogeneral_comments = ngeneral_commentsHTH
    John
    Message was edited by:
    John Spencer
    Honest, Eric wasn't there when I posted :-)

  • Updating tables based on Dates

    In my application I use some tables with a date field.
    table: employee
    period date (e.g. 01-01-2004, 01-02-204, 01-03-2004)
    target money
    result money
    table: project
    date date (e.g. 15-01-2004, 20-01-2004, 03-02-2004)
    revenue money
    If I book a new project the table employee should be updated with result = result + revenue. If there is a new project on 15-01-2004 the record in employee where period = 01-01-2004 should be updated.
    Can someone help me with a sample code for this problem?

    Assuming you have a block in the form call PROJ with fields DATE, REVENUE and EMP_NO. Also that a record exists for the employee and period date.
    Create PRE-INSERT and PRE-UPDATE triggers on the block PROJ containing
    begin
    update employee
    set result=result+:PROJ.REVENUE
    where period_date=trunc(:PROJ.DATE,'Mon')
    and emp_no=:PROJ.EMP_NO;
    end

  • Trying to update table based on combo box choice

    Hey all,
    I have taken over code someone has created and it is confusing me what they have done. the code uses an abstracttablemodel to create the table (and i assume, fill the data). I can't for the life of me, figure out how the data is loaded. Can someone tell me what is happening. also, what would be the easiest way to update it to only show that info that matches the criteria? I will post what i think is relevant code, but if i am missing something, i will be happy to throw it in there. Here's the code:
    public class ABMD extends JPanel implements ActionListener
    private JTable table;
        private TableSorter sorter;
    public ABMD()
    sorter = new TableSorter(new ABMDTableModel());
            table = new JTable(sorter);
            sorter.setTableHeader(table.getTableHeader());
            ListSelectionModel rowSM = table.getSelectionModel();
            rowSM.addListSelectionListener(new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                    if (e.getValueIsAdjusting()) return;
                    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                    if (lsm.isSelectionEmpty())
                        viewDataButton.setEnabled(false);
                        getDataButton.setEnabled(false);
                        removeDataButton.setEnabled(false);
                    else
                        int selectedRow = sorter.modelIndex(table.getSelectedRow());
                        PlanData currentPlanData = (PlanData) planArrayList.get(selectedRow);
                        if (!currentPlanData.getPlanListLoaded())
                            getDataButton.setEnabled(true);
                            viewDataButton.setEnabled(false);
                            removeDataButton.setEnabled(false);
                        else
                            getDataButton.setEnabled(false);
                            viewDataButton.setEnabled(true);
                            removeDataButton.setEnabled(true);
                        String desc = "";
                        desc = currentPlanData.getUniqueID();
                        descTextAreaValue.setText(desc);
    class ABMDTableModel extends AbstractTableModel
            private String[] columnNames = {"Plan Local",
                    "OPLAN",
                    "Air Defense Plan",
                    "Planning Period",
                    "Defense Design",
                    "Published Date"
            public int getColumnCount()
                return columnNames.length;
            public int getRowCount()
                return planArrayList.size();
            public String getColumnName(int col)
                return columnNames[col];
            public Object getValueAt(int row, int col)
                PlanData planData = (PlanData) planArrayList.get(row);
                switch(col)
                    case 0:
                        return Boolean.valueOf(planData.getPlanListLoaded());
                    case 1:
                        return planData.getOplan();
                    case 2:
                        return planData.getAirDefensePlan();
                    case 3:
                        return planData.getPlanningPeriod();
                    case 4:
                        return planData.getDefenseDesign();
                    case 5:
                        return planData.getPublishedDate();
                throw new IllegalArgumentException("Illegal Column: " + getColumnName(col));
            public Class getColumnClass(int c)
                return getValueAt(0, c).getClass();
            public boolean isCellEditable(int row, int col)
                return false;
    }

    I can't for the life of me, figure out how the data is loadedLooking at the get value method we see:
    PlanData planData = (PlanData) planArrayList.get(row);Therefore the data is store in the "planArrayList". So the data is loaded whenever you add data to that ArrayList.

  • Compare two columns and formate based on condition

    I know this dead horse has been beaten and I've read my fair share of threads and manuals to no avail..  I have two list that consist of movie titles, holiday movies to be exact.  I'm creating a holiday movie schedule which consist of three(3) columns...A,B and C.  Column A is the Date, Sat, November 17 2012 thru Monday, Dec 24, 2012.  Column C consist of a movie list divided into 2 sections with three subsections each.  Section 1 is animated movies and Section 2 is live action, each subsection, 1.1, 1.2, 1.3, 2.1, 2.2 and 2.3 are lists based on popularity with the kids...low, medium and high respectively.  And finally column B is the movie list relative the column A...the schedule.
    As I write a movie title in column B, I'd like the cell fill to be light red and the corresponding title in column C change to strike through font type.  This way I know I've added the movie title to the schedule...this comes in handy when I ask the kids to help so we have no duplicates in the schedule.  I'm assuming this would take a combination of; Conditional Formatting, cell formulas and perhaps an additional blank column for trigger results.
    I'm including the table, which include an experimental column I was working on.  As an FYI, this has been completed in Excel already, just hoping to get it done in Numbers.
    Thanks for any help anyone can give.
    Date
    Movie Name
    Class
    Sat, Nov 17, 2012
    Animated Christmas Movies
    TRUE
    Lowest Priority Animation
    TRUE
    Frosty Returns
    TRUE
    Sun, Nov 18, 2012
    The Nightmare Before Christmas
    Rudolph and Frosty's Christmas in July
    TRUE
    Rudolph the Red-Nosed Reindeer & the Island of Misfit Toys
    TRUE
    Rudolph's Shiny New Year
    TRUE
    Mon, Nov 19, 2012
    Nothing Like the Holidays
    TRUE
    Medium Priority Animation
    TRUE
    Jack Frost Animation
    TRUE
    Tue, Nov 20, 2012
    Home for the Holidays
    It's Christmas Time Again, Charlie Brown
    TRUE
    Christmas in South Park
    TRUE
    Cartoon Network Christmas Rocks
    TRUE
    Wed, Nov 21, 2012
    Planes, Trains and Automobiles
    Cartoon Network Christmas Yuletide Follies
    TRUE
    Cartoon Network Christmas Vol3
    TRUE
    Twas the Night Before Christmas
    TRUE
    Thu, Nov 22, 2012
    Planes, Trains and Automobiles
    The Little Drummer Boy
    TRUE
    TRUE
    Highest Priority Animation
    TRUE
    Fri, Nov 23, 2012
    Trapped in Paradise
    The Simpson's Christmas
    TRUE
    A Very Special Family Guy Freakin' Christmas
    TRUE
    Family Guy: Road To The North Pole
    TRUE
    Sat, Nov 24, 2012
    American Dad! The Most Adequate Christmas Ever
    TRUE
    A Charlie Brown Christmas
    TRUE
    The Nightmare Before Christmas
    FALSE
    Sun, Nov 25, 2012
    Die Hard
    Frosty the Snowman
    Die Hard 2
    Hooves of Fire
    How the Grinch Stole Christmas
    Mon, Nov 26, 2012
    Gremlins
    Santa Claus is Comin' to Town
    The Year Without a Santa Claus
    Rudolph, the Red-Nosed Reindeer
    Tue, Nov 27, 2012
    The Ice Harvest
    Live Action Christmas Movies
    Lowest Priority
    Wed, Nov 28, 2012
    Reindeer Games
    National Lampoon's Christmas Vacation 2: Cousin Eddie's Island Adventure
    Chasing Christmas
    The Nativity Story
    Thu, Nov 29, 2012
    Bad Santa
    Unaccompanied Minors
    Jingle All the Way
    Jack Frost Live
    Fri, Nov 30, 2012
    The Shop Around the Corner
    The Santa Clause 3: The Escape Clause
    The Santa Clause 2: The Mrs. Clause
    Sat, Dec 1, 2012
    The Bishop's Wife
    Medium Priority
    0
    Bad Santa
    Bad Santa
    Mixed Nuts
    Mixed Nuts
    Sun, Dec 2, 2012
    The Chronicles of Narnia: The Lion, the Witch and the Wardrobe
    Reindeer Games
    Reindeer Games
    The Ice Harvest
    The Ice Harvest
    The Shop Around the Corner
    The Shop Around the Corner
    Mon, Dec 3, 2012
    Miracle on 34th Street B&W
    The Bishop's Wife
    The Bishop's Wife
    Christmas in Connecticut
    Christmas in Connecticut
    The Chronicles of Narnia: The Lion, the Witch and the Wardrobe
    The Chronicles of Narnia: The Lion, the Witch and the Wardrobe
    Tue, Dec 4, 2012
    Mixed Nuts
    Nothing Like the Holidays
    Nothing Like the Holidays
    Home for the Holidays
    Home for the Holidays
    The Family Man
    The Family Man
    Wed, Dec 5, 2012
    Scrooged
    Miracle on 34th Street 1994
    Miracle on 34th Street 1994
    Miracle on 34th Street B&W
    Miracle on 34th Street B&W
    Just Friends
    Just Friends
    Thu, Dec 6, 2012
    Just Friends
    Trapped in Paradise
    Trapped in Paradise
    0
    Highest Priority
    0
    Fri, Dec 7, 2012
    Miracle on 34th Street 1994
    Die Hard
    Die Hard
    Die Hard 2
    Die Hard 2
    Gremlins
    Gremlins
    Sat, Dec 8, 2012

    Hi Stephen,
    Both of these are solvable, and the Date solution cold be similar to that used for the 'stock list' in column C. The Movie Title solution is a different case, though.
    The stock list is edited only occasionally, so requiring the user to unhide column C, add a title, then rehide the column is workable.
    The same is true of the date list, so this too would work with the dates entered into a column that will be hidden, then copied into a visible column with a formula that introduced a detectable difference into the copied version, dependent on the weekday of each date. That difference would be used to trigger the conditional formatting of the cell containing the calculated date as text value. See the example below.
    But the (scheduled) Movie Title column doesn't fit nicely into that mode of operation, as it is edited quite often. As editing, usng the model described, requires making the data column visible, editing the entry (or entries) in that column, then rehiding the column, the hassle factor soon becomes insufferable, if nothing else.
    The first solution I considered (see earlier reply) is workable only if the the formatted table starts and remains the same size in all details (ie. individual row height) as the main table.Any change in row height in the main table not reflected in the auxiliary table immediately destroys the impression of formatting applying to the correct cells. With cells set to wrap text and varying lengths of movie titles, wrapped lines changing the height of individual rows is pretty much unavoidable.
    Best practice here would seem to be to use a separate column to flag the titles already in the "Class" list with a "√" (or flag those not in the list with an "X"), and use conditional formatting to change the background colour of the flagging cell.
    Here's a sample, using "W" to flag the weekend dates in the new column B, and "√" to flag the titles that are on the list already in the new column D.
    I've added two titles to the weekend date, November 18. One is non-existent (as far as I know), so it doesn't appear in the list and doesn't get flagged; the other is chosen from a visible part of the list to show the highlighting of the title in that list. Column "C" (now column "F" due to the insertion of two new columns) is hidden. G, labelled .Class, is the calculated column (D) from the previous message.
    Regards,
    Barry

Maybe you are looking for

  • Photo streaming question

    I'm not sure where this question ought to be posted, so I apologize if its the wrong section. In anycase, I wish to know how to erase a photo on photo streaming. Thanks!

  • Querying an SQL Database from ABAP

    Is is possible from within ABAP in R/3 (or NetWeaver) to query a non-SAP database? For example, can I write ABAP code which will go after data in say a non SAP DB2 database at some remote location? Kevin

  • Online Database updation for SQLite using Objective-C Language

    Hello Experts, I would like to know if executing scripts (or any apple script) inside apple script possible? I need to have my application to fetch some script from the database field, (like stored procedure) I do not want to compile the application

  • Library keeps corrupting - very frustrating

    I'm running the latest versions of SL and iTunes on a 27" iMac. Library is held on an external Drobo running the latest firmware. Solution has been stable for 18 months+ until this started happening this week. 3 times in the last week, the iTunes lib

  • Device constants search

    Hi everyone, I am currently running into this problem. I wants wondering if anyone can help me out. I am working with a Data graphing program. user select the file to graph. For instant, SN 10001.csv that file is located in folder \Data before we are