Record inserting twice on insert button trigger

hi developers,
I am designing a simple form whilch contains the datablock in tabluar form and showing the data from the table to which the data block is connected...
i have an button INSERT ....when clicking the insert button the record should be inserted....i wrote the trigger as WHEN - BUTTON-INSERTED
insert into anand(empid,empname) values(:anand.empid,:anand.empname);
commit_form;
both data block and table name is anand oly.
when i trigger the insert button the record is inserted twice.....
how to resolve this issue....

Hi,
You can set the Current Record Status to QUERY_STATUS before calling COMMIT_FORM built-in. So the code will be
insert into anand(empid,empname) values(:anand.empid,:anand.empname);
SET_RECORD_PROPERTY(:SYSTEM.CURSOR_RECORD, 'ANAND', STATUS, QUERY_STATUS);
commit_form;Hope this helps.
Regards,
Manu.

Similar Messages

  • Abort inserting a record in a table using a trigger

    Hi there,
    Is there any way to abort inserting a record in a table using a trigger?
    For full details, I have the following table ("myTable"):
    BSC INTEGER NOT NULL,
    BTS VARCHAR2(20) NOT NULL,
    INFO1 INTEGER,
    INFO2 INTEGER
    myTable_PK = PRIMARY KEY (BSC,BTS)
    I have also a stored procedure that imports a data from text file and inserts them to the specified table (using UTL_FILE package). The stored procedure works great.
    But the thing that in the text file itselft it might be (due to third-parity report generation bug) that the primary key will be violated or the BSC/BTS field has null value. In such case I just want to ignore the insertion statement using a trigger.
    Thanks

    Ok Jens, could you tell me what exception could I use?
    Below a protion of my StoredProcedure.
    CREATE OR REPLACE PROCEDURE update_myTable() IS
    FHANDLE UTL_FILE.FILE_TYPE;
    BSC INTEGER;
    BTS VARCHAR2(20);
    INFO1 INTEGER;
    INFO2 INTEGER;
    BEGIN
    FHANDLE := UTL_FILE.FOPEN('LOG_FILE_DIR',FILENAME,'R',4000);
    LOOP
    UTL_FILE.GET_LINE(FHANDLE,STR);
    -- Process the line STR and generates BSC, BTS, INFO1, and INFO2 values
    EXECUTE IMMEDIATE 'INSERT INTO myTable VALUES(:1,:2,:3,:4)' USING BSC,BTS,INFO1,INFO2;
    END LOOP;
    EXCEPTION WHEN NO_DATA_FOUND THEN UTL_FILE.FCLOSE(FHANDLE);
    END UPDATE_R205BTS;
    Remember that I am already using an exception with NO_DATA_FOUND to indicate the end of file then closing it.
    Thanks for your reply

  • Relation between record in a form and insert statement written in button

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i have a master detail form with relation
    A is master of B, B is master of C and a button which resides on control block(other than A,B,C).
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.
    so when i try to move to next record('A' block) it is asking for database change. when i give 'yes' everything is ok. but when i give 'no'(w.r.t that record) and moves to next record and inserts the record and insert record throguh button also, at this time user press 'yes' then the first record is not saving but what ever i have inserted through the insert statement is not rolling back.
    How can i control insert statement with the respect to datablock change in the block.
    The block 'C' data is going to the other table through insert statement the block 'C' i am posting. So due to 'post' the block is not getting cleared so insert statement is also firing.
    In other words i want to unpost the posted data when user press 'no' in the database message.
    I know there is nothing to do with the forms message. But is its possible to control when user press 'no' then the insert statement should not gets saved into the table.
    Please help.
    Thanks..
    Edited by: GD on Jun 27, 2011 5:38 AM

    First off, you need to understand how Oracle Forms interacts with an Oracle database. Forms natively handles all DML transactions for you. Meaning, if you have a Forms data block based on a database table, Forms will generate all the necessary DML to handle any changes that occur in that block. You do not need to write your own DML statements in code.
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.Is Block "A" based on a table? How are you inserting the record into the table? If you are writting your own DML to insert the record this would explain why you are being prompted to save when you change records. As I mentioned, if your block is based on a table, Forms will know if you change a value within the block.
    How can i control insert statement with the respect to datablock change in the block.If your blocks are based on tables, let Forms handle the DML! don't do it yourself.
    In other words i want to unpost the posted data when user press 'no' in the database messageIf your block is based on a table, when you are prompted to save changes - answering 'NO' will automatically clear the current record of the data block (in essence - rollback the change).
    Craig...

  • FRM-40600: Record has already been inserted.

    I am using Form 9i.
    I have written a procedure to save master-detail form which is called when WHEN-BUTTTON-PRESSED trigger written in submit button..
    I have written this procedure because I am confident in writing procedure for save button. But it gives error - 'FRM-40600: Record has already been inserted.'.
    When I was using default (form) for saving record, I was getting lot of message (error). I was getting confused seeing this message. That's why I have written save button procedure. I don't know whether I am doing wrong or right.
    Before posting, I searched in forum also and found some post regarding this, but still I am unable to find the solution.
    Anyway, I am giving you code for save procedure -
    PROCEDURE save_workorder IS
    v_count          NUMBER;
    BEGIN
         SELECT COUNT(*) INTO v_count FROM workorder_master
                                       WHERE workorder_no = :workorder_master.workorder_no;
         IF v_count = 0 THEN
              GO_BLOCK('workorder_master');
              INSERT INTO workorder_master (
                                                                                    vender_code,
                                                                                    workorder_no,
                                                                                    auth_rep,
                                                                                    workplace,
                                                                                    work_desc,
                                                                                    from_dt,
                                                                                    to_dt,
                                                                                    tot_manpower,
                                                                                    gp_manpower,
                                                                                    lic_no,
                                                                                    lic_recpt_no,
                                                                                    lic_valid_upto,
                                                                                    eic_name,
                                                                                    status,
                                                                                    remarks,
                                                                                    entry_by,
                                                                                    entry_dt)
                                                                     VALUES(
                                                                                    :workorder_master.vender_code,
                                                                                    :workorder_master.workorder_no,
                                                                                    :workorder_master.auth_rep,
                                                                                    :workorder_master.workplace,
                                                                                    :workorder_master.work_desc,
                                                                                    :workorder_master.from_dt,
                                                                                    :workorder_master.to_dt,
                                                                                    :workorder_master.tot_manpower,
                                                                                    :workorder_master.gp_manpower,
                                                                                    :workorder_master.lic_no,
                                                                                    :workorder_master.lic_recpt_no,
                                                                                    :workorder_master.lic_valid_upto,
                                                                                    :workorder_master.eic_name,
                                                                                    :workorder_master.status,
                                                                                    :workorder_master.remarks,
                                                                                    :workorder_master.entry_by,
                                                                                    :workorder_master.entry_dt);
              GO_BLOCK('workorder_dtls');
              FIRST_RECORD;
              LOOP
              EXIT WHEN :workorder_dtls.labour_code IS NULL;
              IF :workorder_dtls.pass_no IS NULL THEN
                   generate_pass_no;
                   IF :workorder_dtls.pass_no IS NOT NULL THEN
                             :workorder_dtls.status := 'I';
                             INSERT INTO workorder_dtls (
                                                                                         labour_code,
                                                                                    workorder_no,
                                                                                    pass_no,
                                                                                    status,
                                                                                    from_dt,
                                                                                    to_dt,
                                                                                    cancil_dt,
                                                                                    issue_dt,
                                                                                    return_dt,
                                                                                    entry_by,
                                                                                    entry_dt)
                                                                VALUES (:workorder_dtls.labour_code,
                                                                                    :workorder_dtls.workorder_no,
                                                                                    :workorder_dtls.pass_no,
                                                                                    :workorder_dtls.status,
                                                                                    :workorder_dtls.from_dt,
                                                                                    :workorder_dtls.to_dt,
                                                                                    :workorder_dtls.cancil_dt,
                                                                                    :workorder_dtls.issue_dt,
                                                                                    :workorder_dtls.return_dt,
                                                                                    :workorder_master.entry_by,
                                                                                    :workorder_master.entry_dt);
                   END IF;
                   ELSE --if pass no is not null then it is previous record.
                        UPDATE workorder_dtls SET status           = :workorder_dtls.status,
                                                                                    cancil_dt = :workorder_dtls.cancil_dt,
                                                                                    return_dt = :workorder_dtls.return_dt,
                                                                                    entry_by      = :workorder_dtls.entry_by,
                                                                                    entry_dt      = :workorder_dtls.entry_dt
                                            WHERE labour_code = :workorder_dtls.labour_code
                                            AND workorder_no = :workorder_dtls.workorder_no
                                            AND pass_no = :workorder_dtls.pass_no;
                   END IF;     
                   IF :workorder_dtls.status = 'I' THEN
                   UPDATE labour_master SET status = 'I'
                                       WHERE labour_code = :workorder_dtls.labour_code;
                   END IF;
                   IF :workorder_dtls.status = 'E' THEN
                        IF :workorder_dtls.return_dt IS NOT NULL THEN
                             UPDATE labour_master SET status = 'A'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        ELSE
                             UPDATE labour_master SET status = 'H'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        END IF;
                   END IF;
                   IF :workorder_dtls.status = 'B' THEN
                        IF :workorder_dtls.return_dt IS NOT NULL THEN
                             UPDATE labour_master SET status = 'A'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        ELSE
                             UPDATE labour_master SET status = 'S'
                                                 WHERE labour_code = :workorder_dtls.labour_code;
                        END IF;
                   END IF;
                   NEXT_RECORD;
              END LOOP;
         ELSE --if workorder exist
              GO_BLOCK('workorder_master');
              UPDATE workorder_master SET     auth_rep               =     :workorder_master.auth_rep,
                                                                                    workplace               =     :workorder_master.workplace,
                                                                                    work_desc               =     :workorder_master.work_desc,
                                                                                    from_dt                    =     :workorder_master.from_dt,
                                                                                    to_dt                         =     :workorder_master.to_dt,
                                                                                    tot_manpower     =     :workorder_master.tot_manpower,
                                                                                    gp_manpower          =     :workorder_master.gp_manpower,
                                                                                    lic_no                    =     :workorder_master.lic_no,
                                                                                    lic_recpt_no     =     :workorder_master.lic_recpt_no,
                                                                                    lic_valid_upto=     :workorder_master.lic_valid_upto,
                                                                                    eic_name               =     :workorder_master.eic_name,
                                                                                    status                    =     :workorder_master.status,
                                                                                    remarks                    =     :workorder_master.remarks,
                                                                                    entry_by               =     :workorder_master.entry_by,
                                                                                    entry_dt               =     :workorder_master.entry_dt
                                            WHERE vender_code = :workorder_master.vender_code
                                            AND workorder_no = :workorder_master.workorder_no;
              GO_BLOCK('workorder_dtls');
              FIRST_RECORD;
              LOOP
              EXIT WHEN :workorder_dtls.labour_code IS NULL;
              IF :workorder_dtls.pass_no IS NULL THEN
                   generate_pass_no;
                   IF :workorder_dtls.pass_no IS NOT NULL THEN
                             :workorder_dtls.status := 'I';
                             INSERT INTO workorder_dtls (
                                                                                         labour_code,
                                                                                    workorder_no,
                                                                                    pass_no,
                                                                                    status,
                                                                                    from_dt,
                                                                                    to_dt,
                                                                                    cancil_dt,
                                                                                    issue_dt,
                                                                                    return_dt,
                                                                                    entry_by,
                                                                                    entry_dt)
                                                                VALUES (:workorder_dtls.labour_code,
                                                                                    :workorder_dtls.workorder_no,
                                                                                    :workorder_dtls.pass_no,
                                                                                    :workorder_dtls.status,
                                                                                    :workorder_dtls.from_dt,
                                                                                    :workorder_dtls.to_dt,
                                                                                    :workorder_dtls.cancil_dt,
                                                                                    :workorder_dtls.issue_dt,
                                                                                    :workorder_dtls.return_dt,
                                                                                    :workorder_master.entry_by,
                                                                                    :workorder_master.entry_dt);
                   END IF;
                   ELSE --if pass no is not null then it is previous record.
                        UPDATE workorder_dtls SET status           = :workorder_dtls.status,
                                                                                         cancil_dt = :workorder_dtls.cancil_dt,
                                                                                         return_dt = :workorder_dtls.return_dt,
                                                                                         entry_by      = :workorder_dtls.entry_by,
                                                                                         entry_dt      = :workorder_dtls.entry_dt
                                            WHERE labour_code = :workorder_dtls.labour_code
                                            AND workorder_no = :workorder_dtls.workorder_no
                                            AND pass_no = :workorder_dtls.pass_no;
                   END IF;     
                   IF :workorder_dtls.status = 'I' THEN
                   UPDATE labour_master SET status = 'I'
                                       WHERE labour_code = :workorder_dtls.labour_code;
                   END IF;
                   IF :workorder_dtls.status = 'E' THEN
                        IF :workorder_dtls.return_dt IS NOT NULL THEN
                             UPDATE labour_master SET status = 'A'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        ELSE
                             UPDATE labour_master SET status = 'H'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        END IF;
                   END IF;
                   IF :workorder_dtls.status = 'B' THEN
                        IF :workorder_dtls.return_dt IS NOT NULL THEN
                             UPDATE labour_master SET status = 'A'
                                                      WHERE labour_code = :workorder_dtls.labour_code;
                        ELSE
                             UPDATE labour_master SET status = 'S'
                                                 WHERE labour_code = :workorder_dtls.labour_code;
                        END IF;
                   END IF;
                   NEXT_RECORD;
              END LOOP;
         END IF;
         COMMIT;
    END;
    Thanks and regards,
    Vikas

    Yes Sir, why not.
    This procedure is written in KEY-NEXT-ITEM of workorder_no, the only trigger in workorder_no. Block level-trigger is also there. like ON-POPULATE-DETAILS, ON-CHECK-DELETE-MASTER.
    Thanks and regards,
    Vikas
    [HTML]
    DECLARE
         V_VENDER_CODE NUMBER;
         REL_ID RELATION;
    BEGIN
    BEGIN     
    SELECT VENDER_CODE INTO V_VENDER_CODE FROM WORKORDER_MASTER WHERE WORKORDER_NO = :WORKORDER_MASTER.WORKORDER_NO ;
                   :BLK_TEMP_WORKORDER.WORKORDER_NO := :WORKORDER_MASTER.WORKORDER_NO;
                   :BLK_TEMP_WORKORDER.VENDER_CODE := V_VENDER_CODE;
         IF ( (:WORKORDER_MASTER.WORKORDER_NO is not null) ) THEN  
             rel_id := Find_Relation('WORKORDER_MASTER.WORKORDER_MASTE_WORKORDER_DTLS');  
             Query_Master_Details(rel_id, 'WORKORDER_DTLS');
          SET_ITEM_PROPERTY('BLK_TEMP_WORKORDER.CB_ALL' , ENABLED , PROPERTY_TRUE);
         END IF;
                   GO_BLOCK('WORKORDER_MASTER');
                   EXECUTE_QUERY(NO_VALIDATE);
                   GO_BLOCK('WORKORDER_MASTER_IMG');
                   EXECUTE_QUERY(NO_VALIDATE);
                   :WORKORDER_MASTER.VENDER_CODE := :BLK_TEMP_WORKORDER.VENDER_CODE;
                   :WORKORDER_MASTER.WORKORDER_NO := :BLK_TEMP_WORKORDER.WORKORDER_NO ;
           GO_ITEM('WORKORDER_MASTER.AUTH_REP');
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         MESSAGE('NO VENDER HAVING WORKORDER NO. '||:WORKORDER_MASTER.WORKORDER_NO ||' EXIST.');
         IF :WORKORDER_MASTER.VENDER_CODE IS NULL THEN
              GO_ITEM('WORKORDER_MASTER.VENDER_CODE');
         ELSE
                :BLK_TEMP_WORKORDER.WORKORDER_NO := :WORKORDER_MASTER.WORKORDER_NO;
                   :BLK_TEMP_WORKORDER.VENDER_CODE := :WORKORDER_MASTER.VENDER_CODE;
                GO_BLOCK('WORKORDER_MASTER');
                   EXECUTE_QUERY(NO_VALIDATE);
                   GO_BLOCK('WORKORDER_MASTER_IMG');
                   EXECUTE_QUERY(NO_VALIDATE);
                   :WORKORDER_MASTER.VENDER_CODE := :BLK_TEMP_WORKORDER.VENDER_CODE;
                   :WORKORDER_MASTER.WORKORDER_NO := :BLK_TEMP_WORKORDER.WORKORDER_NO ;
          SELECT name INTO :workorder_master.auth_rep FROM contractor_master
                                        WHERE vender_code = :workorder_master.vender_code;
          GO_ITEM('WORKORDER_MASTER.AUTH_REP');
         END IF;
    END;
    END;[HTML]

  • How to insert a pdf export button in a module

    Hi,
    I would propose a way for my students to realize easily a pdf export of one screen. The goal is that students save a file with a drag and drop exercice in order to re-use after.
    So, I tried :
    - Use a shape and execute Javascript, window.print(). I had think to say students to use pdf export instead of print. In my case, print works only in html5. In flash, only the background is displaying.
    - Use the print widget of captivate. It works but it's hard to use it. Student needs to edit properties to choose layout / paper size. Otherwise, some part of the screen are not displaying.
    So I'm looking a solution to insert a pdf export button. Idealy a student clicks up the button and screen will be export in pdf format.  I try this wdiget (http://captivatedev.com/2012/07/25/adobe-captivate-6-x-widget-dynamic-pdf-export/) but we can export only variables.
    Anyone has a good idea to share ?
    Best regards.
    Clément

    Thank you Pat. The thing is that i can´t upload any document to the web server because it belongs to "Jimdo". They give the option with a kind of Plugin and the Pdf comes directly from your browser to be download from the visitors, but it look ugly. That´s why I inserted a link to go to another page (different server) where I can upload documents. I think a need someone who know Jimdo.
    Thank you

  • Find records based on their insertion order

    Hi to all,
    Is there any way I can find records based on their insertion order.
    Like i inserted 5 records, can I find fifth record based on that insertion order?
    Advance thanks for your inputs
    Regards
    Karthik

    Not without adding some kind of sequencing mechanism to your inserts.
    You could use sequence numbers, or for more robustness, insert timestamps alongside your inserts.
    Triggers will help you to acheive this.

  • Difference between Before INSERT and After INSERT trigger?

    What is difference between Before INSERT and After INSERT triggers? Can anyone give me a simple example from SCOTT schema for both of these triggers.

    The documentation gives a good explanation have you looked at....
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1175

  • Post-insert vs pre-insert

    Dear All,
    can anybody explain the difference b/w pre-insert and post-insert trigger ?
    i need such example which process something that becomes possible in one trigger and no possible in other ?
    Regards
    Kashif Butt

    Here is an example. Please remove any syntax errors before running :-)
    create sequence my_seq;
    create table table_a
    (id number(20) constraint pk_table_a primary key,
    text varchar2(100)
    create table table_b
    (id number(20) constraint pk_table_b primary key,
    a_id number(20) constraint fk1_table_b foreign key references table_a(id),
    text varchar2(100)
    Create a form with a block based on table_a with items "id" and "text"
    "id" is on null canvas (not visible), put "text" on a canvas.
    pre-insert:
    select my_seq.nextval into :table_a.id;
    This can't be done in post-insert. Then the insert will fail because it's the primary key and must be "not null"
    post-insert:
    insert into table_b(id, a_id, text)
    values(my_seq.nextval, :table_a.id, 'Inserted automatically by post-insert');
    This can't be done in the pre-insert trigger, because the foreign key constraint will require the record in table_a
    to be inserted first.

  • Insert Link and Insert Image broken in Chrome

    The Insert Link and Insert Image buttons have been broken in my Chrome for at least the last couple of days (latest version, 32.0.1700.72 m, Windows 7 64).  
    When you click one of the buttons, the overlay window appears with a title, but it is otherwise black with no contents.  (See screenshot below.)
    The buttons work fine in Firefox.  What hasn't helped: deleting cookies, clearing the browser cache, waiting for several minutes for their content to appear.

    Whtat are we supposed to Claudio? All descend on Adobe with  clubs and try to beat some sense into someone!
    The fact is the customer is no longer the prime concern. Most companies don't give a Rats behind (toned down to prevent censors action) about the customers. It's the almighty dollar. Screw as many customers as they can while they can and line their pockets with all the green backs  as they can while they can. Then if the cusomers leave so be they take their money and run.
    Customer use to have power, they would speak loud and frequently and get things  fixed. And what with people from other countries now owning US companies, That were brought up with different moral compasses. They have no concept of this thing of loyalty to customers. The customer can jump off a cliff and they will simply cheer them on while the do so.
    We have lost, the fight can't be won. It no use. So Pat and others are right.
    I've been trying for 15 years for adobe to fix the issue of having multiple Pdfs created from Office documents because the claim they can't figure out how MS does Page and section breaks. And the issue of Weblinks not being active when converted to PDF's Both on Mac's yet on PC's there is no issue. I quite this year after I received a down right nasty not from Adobe say they didn't have any interest in fixing the bugs and were not about to try. What it amounted was go take a flying leap.
    They have the ability. They have beenblaming Its apple because they don't do such and such , or Microsoft because they don't do so and such. On the Links issue Saying MS doesn't provided the necessary hooks in the mac version of Office. They do you can take a Word document created on a Mac and open a PC and create a PDF and the links will be active. You can Open a Word Document in Apple's pages and all links created in Office document will be there.  The argument has been proven several different ways to be a an outright bald-faced lie. The defect is squarely with the Mac version of Acrobat.
    So Pat and others are right. Just throw in that towel. Adobe support of its customers is now 10 times worse than intuit's which is supposed have the lowest reputation of any software compny that ever existed.

  • Instead of Insert, Verify not inserting into identity column.

    I am writing an Instead of Insert trigger. I would like to fire an error when inserting into an 'Identity' column.  Since UPDATE([ColumnName]) always returns TRUE for insert statements, is there an easy/fast way around this? I don't
    want to use: 
    IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NULL))
    here is my pseudo-code...
    CREATE VIEW [org].[Assets]
    WITH SCHEMABINDING
    AS
    SELECT
    [AS].[AS_ID], -- Identity field in base table
    [AS].[Tag],
    [AS].[Name]
    FROM [org].[AS_Assets_Rewind](DEFAULT, DEFAULT, DEFAULT) [AS];
    GO
    CREATE TRIGGER [org].[Assets_Insert]
    ON [org].[Assets]
    INSTEAD OF INSERT
    AS
    BEGIN
    SET NOCOUNT ON;
    SET XACT_ABORT ON;
    -- How does this statment need to be written to throw the error?
    -- UPDATE([AS_ID]) always returns TRUE
    IF(UPDATE([AS_ID]))
    RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    -- Is there a faster/better method than this?
    IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NOT NULL))
    RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    -- Do Stuff
    END;
    -- Should error for inserting into [AS_ID] field (which is an identity field)
    INSERT INTO [org].[Assets]([AS_ID], [Tag], [Name])
    VALUES(1, 'f451', 'Paper burns'),
    (2, 'k505.928', 'Paper burns in Chemistry');
    -- No error should occur
    INSERT INTO [org].[Assets]([Tag], [Name])
    VALUES('f451', 'Paper burns'),
    ('k505.928', 'Paper burns in Chemistry');

    IDENTITY is in single quotes, maybe i should have made it italics to indicate it is not the name of the column, but a logical reference to a column that has the identity property set.
    the "_Rewind" suffix is to indicate the function "looks back into time".
    Schema design is wrong? How do you recommend creating a SQL Server 2012 database that can
    1) keep a history of data with respect to changing time and transaction time
    2) update data that does not arrive at one time, aka, I may get your name and phone number today, but your e-mail address tomorrow - we need to be able to differentiate when different data was updated.
    3) no physical deletes (due to needing to go back in time)
    FYI: 
    I have examined R. Snodgrass's, L. Rönnbäck's, and T. Johnston's bi-temporal design patterns.
    here is the DDL:
    CREATE SCHEMA [posit];
    GO
    CREATE SCHEMA [org];
    GO
    CREATE TABLE [posit].[PO_Positor]
    [PO_PositorId] INT NOT NULL IDENTITY(1, 1),
    [PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
    [PO_PositorName] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
    [PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
    CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
    [PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
    [PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
    [PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
    [PO_PositorInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorInserted] DEFAULT(SYSDATETIMEOFFSET()),
    [PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
    CONSTRAINT [PK__PO_Positor] PRIMARY KEY ([PO_PositorId] ASC),
    CONSTRAINT [UK__PO_Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC)
    GO
    CREATE PROCEDURE [posit].[Insert_Positor]
    @PositorNote NVARCHAR(348) = NULL
    AS
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(261) = N'[' + OBJECT_SCHEMA_NAME(@@PROCID) + N'].[' + OBJECT_NAME(@@PROCID) + N']';
    SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
    DECLARE @Id TABLE
    [Id] INT NOT NULL
    INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
    OUTPUT [inserted].[PO_PositorId]
    INTO @Id([Id])
    VALUES (@PositorNote);
    RETURN (SELECT TOP 1 [i].[Id] FROM @Id [i]);
    END;
    GO
    CREATE PROCEDURE [posit].[Return_PositorId]
    AS
    BEGIN
    DECLARE @PositorId INT = [posit].[Get_PositorId]();
    IF (@PositorId IS NULL)
    BEGIN
    DECLARE @ProcedureDesc NVARCHAR(261) = N'[' + OBJECT_SCHEMA_NAME(@@PROCID) + N'].[' + OBJECT_NAME(@@PROCID) + N']';
    DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
    EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
    END;
    RETURN @PositorId;
    END;
    GO
    CREATE FUNCTION [posit].[Get_PositorId]
    RETURNS INT
    AS
    BEGIN
    DECLARE @PositorId INT = NULL;
    SELECT TOP 1
    @PositorId = [p].[PO_PositorId]
    FROM
    [posit].[PO_Positor] [p]
    WHERE [p].[PO_PositorApp] = APP_NAME()
    AND [p].[PO_PositorHost] = HOST_NAME()
    AND [p].[PO_PositorUID] = SUSER_ID();
    RETURN @PositorId;
    END;
    GO
    CREATE TABLE [org].[AS_Assets]
    [AS_ID] INT NOT NULL IDENTITY(1, 1),
    [AS_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_Assets_PositedBy] DEFAULT([posit].[Get_PositorId]())
    CONSTRAINT [FK__AS_Assets_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
    [AS_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_Assets_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
    [AS_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_Assets_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__AS_Assets_RowGuid] UNIQUE([AS_RowGuid]),
    CONSTRAINT [PK__AS_Assets] PRIMARY KEY CLUSTERED ([AS_ID] ASC)
    GO
    CREATE TABLE [org].[AS_NME_Assets_Name_Posit]
    [AS_NME_ID] INT NOT NULL IDENTITY(1, 1),
    [AS_NME_AS_ID] INT NOT NULL CONSTRAINT [FK__AS_NME_Assets_Name_Posit_AS_NME_AS_ID] REFERENCES [org].[AS_Assets]([AS_ID]),
    [AS_NME_AssetTag] VARCHAR(12) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetTag] CHECK([AS_NME_AssetTag] <> ''),
    [AS_NME_AssetName] NVARCHAR(24) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetName] CHECK([AS_NME_AssetName] <> ''),
    [AS_NME_AssetDetail] NVARCHAR(48) NOT NULL CONSTRAINT [CL__AS_NME_Assets_Name_Posit_AS_NME_AssetDetail] CHECK([AS_NME_AssetDetail] <> ''),
    [AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
    PERSISTED NOT NULL,
    [AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Posit_ChangedAt] DEFAULT(SYSDATETIMEOFFSET()),
    [AS_NME_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Posit_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__AS_NME_Assets_Name_Posit_RowGuid] UNIQUE NONCLUSTERED([AS_NME_RowGuid]),
    CONSTRAINT [PK__AS_NME_Assets_Name_Posit] PRIMARY KEY([AS_NME_ID] ASC),
    CONSTRAINT [UK__AS_NME_Assets_Name_Posit] UNIQUE CLUSTERED([AS_NME_AS_ID] ASC, [AS_NME_ChangedAt] DESC, [AS_NME_Checksum] ASC)
    WITH (FILLFACTOR = 95)
    GO
    CREATE TABLE [org].[AS_NME_Assets_Name_Annex]
    [AS_NME_ID] INT NOT NULL CONSTRAINT [FK__AS_NME_Assets_Name_Annex_AS_NME_ID] REFERENCES [org].[AS_NME_Assets_Name_Posit]([AS_NME_ID]),
    [AS_NME_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositedBy] DEFAULT([posit].[Get_PositorId]())
    CONSTRAINT [FK__AS_NME_Assets_Name_Annex_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
    [AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
    [AS_NME_PositReliability] TINYINT NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_PositRel] DEFAULT(50),
    [AS_NME_PositReliable] AS CONVERT(BIT, CASE WHEN [AS_NME_PositReliability] > 0 THEN 1 ELSE 0 END)
    PERSISTED NOT NULL,
    [AS_NME_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_NME_Assets_Name_Annex_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__AS_NME_Assets_Name_Annex_RowGuid] UNIQUE NONCLUSTERED([AS_NME_RowGuid]),
    CONSTRAINT [PK__AS_NME_Assets_Name_Annex] PRIMARY KEY CLUSTERED([AS_NME_ID] ASC, [AS_NME_PositedAt] DESC, [AS_NME_PositedBy] ASC)
    WITH (FILLFACTOR = 95)
    GO
    CREATE TABLE [org].[AS_GEO_Assets_Location_Posit]
    [AS_GEO_ID] INT NOT NULL IDENTITY(1, 1),
    [AS_GEO_AS_ID] INT NOT NULL CONSTRAINT [FK__AS_GEO_Assets_Location_Posit_AS_GEO_AS_ID] REFERENCES [org].[AS_Assets]([AS_ID]),
    [AS_GEO_Longitude_Deg] DECIMAL(17, 14) NOT NULL CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Longitude_Deg_L] CHECK([AS_GEO_Longitude_Deg] >= -180.0),
    CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Longitude_Deg_U] CHECK([AS_GEO_Longitude_Deg] <= 180.0),
    [AS_GEO_Latitude_Deg] DECIMAL(17, 14) NOT NULL CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Latitude_Deg_L] CHECK([AS_GEO_Latitude_Deg] >= -90.0),
    CONSTRAINT [CR__AS_GEO_Assets_Location_Posit_Latitude_Deg_U] CHECK([AS_GEO_Latitude_Deg] <= 90.0),
    [AS_GEO_Wgs84] AS geography::STPointFromText('POINT(' + CONVERT(VARCHAR(19), [AS_GEO_Longitude_Deg], 0) + ' ' + CONVERT(VARCHAR(19), [AS_GEO_Latitude_Deg], 0) + ')', 4326),
    [AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
    PERSISTED NOT NULL,
    [AS_GEO_ChangedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Posit_ChangedAt] DEFAULT(SYSDATETIMEOFFSET()),
    [AS_GEO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Posit_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__AS_GEO_Assets_Location_Posit_RowGuid] UNIQUE NONCLUSTERED([AS_GEO_RowGuid]),
    CONSTRAINT [PK__AS_GEO_Assets_Location_Posit] PRIMARY KEY([AS_GEO_ID] ASC),
    CONSTRAINT [UK__AS_GEO_Assets_Location_Posit] UNIQUE CLUSTERED([AS_GEO_AS_ID] ASC, [AS_GEO_ChangedAt] DESC, [AS_GEO_Checksum] ASC)
    WITH (FILLFACTOR = 95)
    GO
    CREATE TABLE [org].[AS_GEO_Assets_Location_Annex]
    [AS_GEO_ID] INT NOT NULL CONSTRAINT [FK__AS_GEO_Assets_Location_Annex_AS_GEO_ID] REFERENCES [org].[AS_GEO_Assets_Location_Posit]([AS_GEO_ID]),
    [AS_GEO_PositedBy] INT NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositedBy] DEFAULT([posit].[Get_PositorId]())
    CONSTRAINT [FK__AS_GEO_Assets_Location_Annex_PositedBy] REFERENCES [posit].[PO_Positor]([PO_PositorId]),
    [AS_GEO_PositedAt] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositedAt] DEFAULT(SYSDATETIMEOFFSET()),
    [AS_GEO_PositReliability] TINYINT NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_PositRel] DEFAULT(50),
    [AS_GEO_PositReliable] AS CONVERT(BIT, CASE WHEN [AS_GEO_PositReliability] > 0 THEN 1 ELSE 0 END)
    PERSISTED NOT NULL,
    [AS_GEO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__AS_GEO_Assets_Location_Annex_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
    CONSTRAINT [UX__AS_GEO_Assets_Location_Annex_RowGuid] UNIQUE NONCLUSTERED([AS_GEO_RowGuid]),
    CONSTRAINT [PK__AS_GEO_Assets_Location_Annex] PRIMARY KEY CLUSTERED([AS_GEO_ID] ASC, [AS_GEO_PositedAt] DESC, [AS_GEO_PositedBy] ASC)
    WITH (FILLFACTOR = 95)
    GO
    CREATE FUNCTION [org].[AS_NME_Assets_Name_Posit_RW]
    @ChangedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [p].[AS_NME_ID],
    [p].[AS_NME_AS_ID],
    [p].[AS_NME_AssetTag],
    [p].[AS_NME_AssetName],
    [p].[AS_NME_AssetDetail],
    [p].[AS_NME_Checksum],
    [p].[AS_NME_ChangedAt]
    FROM
    [org].[AS_NME_Assets_Name_Posit] [p]
    WHERE
    [p].[AS_NME_ChangedAt] < @ChangedBefore;
    GO
    CREATE FUNCTION [org].[AS_NME_Assets_Name_Annex_RW]
    @PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [a].[AS_NME_ID],
    [a].[AS_NME_PositedBy],
    [a].[AS_NME_PositedAt],
    [a].[AS_NME_PositReliability],
    [a].[AS_NME_PositReliable]
    FROM
    [org].[AS_NME_Assets_Name_Annex] [a]
    WHERE[a].[AS_NME_PositedAt] < @PositedBefore;
    GO
    CREATE FUNCTION [org].[AS_NME_Assets_Name_RW]
    @ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
    @PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [p].[AS_NME_ID],
    [p].[AS_NME_AS_ID],
    [p].[AS_NME_AssetTag],
    [p].[AS_NME_AssetName],
    [p].[AS_NME_AssetDetail],
    [p].[AS_NME_Checksum],
    [p].[AS_NME_ChangedAt],
    [a].[AS_NME_PositedBy],
    [a].[AS_NME_PositedAt],
    [a].[AS_NME_PositReliability],
    [a].[AS_NME_PositReliable]
    FROM
    [org].[AS_NME_Assets_Name_Posit_RW](@ChangedBefore) [p]
    INNER JOIN
    [org].[AS_NME_Assets_Name_Annex_RW](@PositedBefore) [a]
    ON [a].[AS_NME_ID] = [p].[AS_NME_ID]
    AND [a].[AS_NME_PositedAt] = (
    SELECT TOP 1
    [s].[AS_NME_PositedAt]
    FROM
    [org].[AS_NME_Assets_Name_Annex_RW](@PositedBefore) [s]
    WHERE [s].[AS_NME_ID] = [p].[AS_NME_ID]
    ORDER BY
    [s].[AS_NME_PositedAt] DESC
    GO
    CREATE FUNCTION [org].[AS_GEO_Assets_Location_Posit_RW]
    @ChangedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [p].[AS_GEO_ID],
    [p].[AS_GEO_AS_ID],
    [p].[AS_GEO_Longitude_Deg],
    [p].[AS_GEO_Latitude_Deg],
    [p].[AS_GEO_Wgs84],
    [p].[AS_GEO_Checksum],
    [p].[AS_GEO_ChangedAt]
    FROM
    [org].[AS_GEO_Assets_Location_Posit] [p]
    WHERE
    [p].[AS_GEO_ChangedAt] < @ChangedBefore;
    GO
    CREATE FUNCTION [org].[AS_GEO_Assets_Location_Annex_RW]
    @PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [a].[AS_GEO_ID],
    [a].[AS_GEO_PositedBy],
    [a].[AS_GEO_PositedAt],
    [a].[AS_GEO_PositReliability],
    [a].[AS_GEO_PositReliable]
    FROM
    [org].[AS_GEO_Assets_Location_Annex] [a]
    WHERE
    [a].[AS_GEO_PositedAt] < @PositedBefore;
    GO
    CREATE FUNCTION [org].[AS_GEO_Assets_Location_RW]
    @ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
    @PositedBefore DATETIMEOFFSET(7) = '9999-12-31'
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [p].[AS_GEO_ID],
    [p].[AS_GEO_AS_ID],
    [p].[AS_GEO_Longitude_Deg],
    [p].[AS_GEO_Latitude_Deg],
    [p].[AS_GEO_Wgs84],
    [p].[AS_GEO_Checksum],
    [p].[AS_GEO_ChangedAt],
    [a].[AS_GEO_PositedBy],
    [a].[AS_GEO_PositedAt],
    [a].[AS_GEO_PositReliability],
    [a].[AS_GEO_PositReliable]
    FROM
    [org].[AS_GEO_Assets_Location_Posit_RW](@ChangedBefore) [p]
    INNER JOIN
    [org].[AS_GEO_Assets_Location_Annex_RW](@PositedBefore) [a]
    ON [a].[AS_GEO_ID] = [p].[AS_GEO_ID]
    AND [a].[AS_GEO_PositedAt] = (
    SELECT TOP 1
    [s].[AS_GEO_PositedAt]
    FROM
    [org].[AS_GEO_Assets_Location_Annex_RW](@PositedBefore) [s]
    WHERE [s].[AS_GEO_ID] = [p].[AS_GEO_ID]
    ORDER BY
    [s].[AS_GEO_PositedAt] DESC
    GO
    CREATE FUNCTION [org].[AS_Assets_Rewind]
    @ChangedBefore DATETIMEOFFSET(7) = '9999-12-31',
    @PositedBefore DATETIMEOFFSET(7) = '9999-12-31',
    @Reliable BIT = 1
    RETURNS TABLE
    WITH SCHEMABINDING
    AS
    RETURN
    SELECT
    [AS].[AS_ID],
    [AS].[AS_PositedBy],
    [AS].[AS_PositedAt],
    [NME].[AS_NME_ID],
    [NME].[AS_NME_AS_ID],
    [NME].[AS_NME_AssetTag],
    [NME].[AS_NME_AssetName],
    [NME].[AS_NME_AssetDetail],
    [NME].[AS_NME_Checksum],
    [NME].[AS_NME_ChangedAt],
    [NME].[AS_NME_PositedBy],
    [NME].[AS_NME_PositedAt],
    [NME].[AS_NME_PositReliability],
    [NME].[AS_NME_PositReliable],
    [GEO].[AS_GEO_ID],
    [GEO].[AS_GEO_AS_ID],
    [GEO].[AS_GEO_Longitude_Deg],
    [GEO].[AS_GEO_Latitude_Deg],
    [GEO].[AS_GEO_Wgs84],
    [GEO].[AS_GEO_Checksum],
    [GEO].[AS_GEO_ChangedAt],
    [GEO].[AS_GEO_PositedBy],
    [GEO].[AS_GEO_PositedAt],
    [GEO].[AS_GEO_PositReliability],
    [GEO].[AS_GEO_PositReliable]
    FROM
    [org].[AS_Assets] [AS]
    INNER JOIN
    [org].[AS_NME_Assets_Name_RW](@ChangedBefore, @PositedBefore) [NME]
    ON [NME].[AS_NME_AS_ID] = [AS].[AS_ID]
    AND [NME].[AS_NME_PositReliable] = @Reliable
    AND [NME].[AS_NME_ID] = (
    SELECT TOP 1
    [NME_s].[AS_NME_ID]
    FROM
    [org].[AS_NME_Assets_Name_RW](@ChangedBefore, @PositedBefore) [NME_s]
    WHERE [NME_s].[AS_NME_AS_ID] = [AS].[AS_ID]
    ORDER BY
    [NME_s].[AS_NME_ChangedAt] DESC,
    [NME_s].[AS_NME_PositedAt] DESC
    LEFT OUTER JOIN
    [org].[AS_GEO_Assets_Location_RW](@ChangedBefore, @PositedBefore) [GEO]
    ON [GEO].[AS_GEO_AS_ID] = [AS].[AS_ID]
    AND [GEO].[AS_GEO_PositReliable] = @Reliable
    AND [GEO].[AS_GEO_ID] = (
    SELECT TOP 1
    [GEO_s].[AS_GEO_ID]
    FROM
    [org].[AS_GEO_Assets_Location_RW](@ChangedBefore, @PositedBefore) [GEO_s]
    WHERE [GEO_s].[AS_GEO_AS_ID] = [AS].[AS_ID]
    ORDER BY
    [GEO_s].[AS_GEO_ChangedAt] DESC,
    [GEO_s].[AS_GEO_PositedAt] DESC
    GO
    CREATE VIEW [org].[AS_NME_Assets_Name_SK]
    WITH SCHEMABINDING
    AS
    SELECT
    [p].[AS_NME_ID],
    [p].[AS_NME_AS_ID],
    [p].[AS_NME_AssetTag],
    [p].[AS_NME_AssetName],
    [p].[AS_NME_AssetDetail],
    [p].[AS_NME_Checksum],
    [p].[AS_NME_ChangedAt],
    [a].[AS_NME_PositedBy],
    [a].[AS_NME_PositedAt],
    [a].[AS_NME_PositReliability],
    [a].[AS_NME_PositReliable]
    FROM
    [org].[AS_NME_Assets_Name_Posit] [p]
    INNER JOIN
    [org].[AS_NME_Assets_Name_Annex] [a]
    ON [a].[AS_NME_ID] = [p].[AS_NME_ID];
    GO
    CREATE UNIQUE CLUSTERED INDEX [PK__AS_NME_Assets_Name_SK]
    ON [org].[AS_NME_Assets_Name_SK]
    [AS_NME_AS_ID] ASC,
    [AS_NME_ChangedAt] DESC,
    [AS_NME_PositedAt] DESC,
    [AS_NME_PositedBy] ASC,
    [AS_NME_PositReliable] ASC
    WITH (FILLFACTOR = 95);
    GO
    CREATE VIEW [org].[AS_GEO_Assets_Location_SK]
    WITH SCHEMABINDING
    AS
    SELECT
    [p].[AS_GEO_ID],
    [p].[AS_GEO_AS_ID],
    [p].[AS_GEO_Wgs84],
    [p].[AS_GEO_Checksum],
    [p].[AS_GEO_ChangedAt],
    [a].[AS_GEO_PositedBy],
    [a].[AS_GEO_PositedAt],
    [a].[AS_GEO_PositReliability],
    [a].[AS_GEO_PositReliable]
    FROM
    [org].[AS_GEO_Assets_Location_Posit] [p]
    INNER JOIN
    [org].[AS_GEO_Assets_Location_Annex] [a]
    ON [a].[AS_GEO_ID] = [p].[AS_GEO_ID];
    GO
    CREATE UNIQUE CLUSTERED INDEX [PK__AS_GEO_Assets_Location_SK]
    ON [org].[AS_GEO_Assets_Location_SK]
    [AS_GEO_AS_ID] ASC,
    [AS_GEO_ChangedAt] DESC,
    [AS_GEO_PositedAt] DESC,
    [AS_GEO_PositedBy] ASC,
    [AS_GEO_PositReliable] ASC
    WITH (FILLFACTOR = 95);
    GO
    CREATE VIEW [org].[AS_Assets_Current]
    WITH SCHEMABINDING
    AS
    SELECT
    [AS].[AS_ID],
    [AS].[AS_PositedBy],
    [AS].[AS_PositedAt],
    [AS].[AS_NME_ID],
    [AS].[AS_NME_AS_ID],
    [AS].[AS_NME_AssetTag],
    [AS].[AS_NME_AssetName],
    [AS].[AS_NME_AssetDetail],
    [AS].[AS_NME_Checksum],
    [AS].[AS_NME_ChangedAt],
    [AS].[AS_NME_PositedBy],
    [AS].[AS_NME_PositedAt],
    [AS].[AS_NME_PositReliability],
    [AS].[AS_NME_PositReliable],
    [AS].[AS_GEO_ID],
    [AS].[AS_GEO_AS_ID],
    [AS].[AS_GEO_Longitude_Deg],
    [AS].[AS_GEO_Latitude_Deg],
    [AS].[AS_GEO_Wgs84],
    [AS].[AS_GEO_Checksum],
    [AS].[AS_GEO_ChangedAt],
    [AS].[AS_GEO_PositedBy],
    [AS].[AS_GEO_PositedAt],
    [AS].[AS_GEO_PositReliability],
    [AS].[AS_GEO_PositReliable]
    FROM [org].[AS_Assets_Rewind](DEFAULT, DEFAULT, DEFAULT) [AS];
    GO
    CREATE TRIGGER [org].[AS_Assets_Current_Insert]
    ON [org].[AS_Assets_Current]
    INSTEAD OF INSERT
    AS
    BEGIN
    SET NOCOUNT ON;
    SET XACT_ABORT ON;
    IF(EXISTS(SELECT [i].[AS_ID] FROM [inserted] [i] WHERE [i].[AS_ID] IS NOT NULL))
    RAISERROR('INSERT into the anchor identity column ''AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_NME_ID] FROM [inserted] [i] WHERE [i].[AS_NME_ID] IS NOT NULL))
    RAISERROR('INSERT into the identity column ''AS_NME_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_NME_AS_ID] FROM [inserted] [i] WHERE [i].[AS_NME_AS_ID] IS NOT NULL))
    RAISERROR('INSERT into the foreign key identity column ''AS_NME_AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_NME_Checksum] FROM [inserted] [i] WHERE [i].[AS_NME_Checksum] IS NOT NULL))
    RAISERROR('INSERT into the computed column ''AS_NME_Checksum'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_NME_PositReliable] FROM [inserted] [i] WHERE [i].[AS_NME_PositReliable] IS NOT NULL))
    RAISERROR('INSERT into the computed column ''AS_NME_PositReliable'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_GEO_ID] FROM [inserted] [i] WHERE [i].[AS_GEO_ID] IS NOT NULL))
    RAISERROR('INSERT into the identity column ''AS_GEO_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_GEO_AS_ID] FROM [inserted] [i] WHERE [i].[AS_GEO_AS_ID] IS NOT NULL))
    RAISERROR('INSERT into the foreign key identity column ''AS_GEO_AS_ID'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_GEO_Checksum] FROM [inserted] [i] WHERE [i].[AS_GEO_Checksum] IS NOT NULL))
    RAISERROR('INSERT into the computed column ''AS_GEO_Checksum'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_GEO_PositReliable] FROM [inserted] [i] WHERE [i].[AS_GEO_PositReliable] IS NOT NULL))
    RAISERROR('INSERT into the computed column ''AS_GEO_PositReliable'' is not allowed.', 16, 1) WITH NOWAIT;
    IF(EXISTS(SELECT [i].[AS_GEO_Wgs84] FROM [inserted] [i] WHERE [i].[AS_GEO_Wgs84] IS NOT NULL))
    RAISERROR('INSERT into the computed column ''AS_GEO_Wgs84'' is not allowed.', 16, 1) WITH NOWAIT;
    DECLARE @Reliability INT = 50;
    DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
    DECLARE @PositedBy INT;
    EXECUTE @PositedBy = [posit].[Return_PositorId];
    DECLARE @Inserted TABLE
    [AS_PositedBy] INT NOT NULL,
    [AS_PositedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_AssetTag] VARCHAR(12) NOT NULL CHECK([AS_NME_AssetTag] <> ''),
    [AS_NME_AssetName] NVARCHAR(24) NOT NULL CHECK([AS_NME_AssetName] <> ''),
    [AS_NME_AssetDetail] NVARCHAR(48) NOT NULL CHECK([AS_NME_AssetDetail] <> ''),
    [AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
    PERSISTED NOT NULL,
    [AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_PositedBy] INT NOT NULL,
    [AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_PositReliability] TINYINT NOT NULL,
    [AS_GEO_Longitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Longitude_Deg] >= -180.0), CHECK([AS_GEO_Longitude_Deg] <= 180.0),
    [AS_GEO_Latitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Latitude_Deg] >= -90.0), CHECK([AS_GEO_Latitude_Deg] <= 90.0),
    [AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
    PERSISTED NOT NULL,
    [AS_GEO_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_GEO_PositedBy] INT NOT NULL,
    [AS_GEO_PositedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_GEO_PositReliability] TINYINT NOT NULL,
    [ROW_ID] INT NOT NULL,
    PRIMARY KEY([ROW_ID] ASC)
    INSERT INTO @Inserted
    [AS_PositedBy],
    [AS_PositedAt],
    [AS_NME_AssetTag],
    [AS_NME_AssetName],
    [AS_NME_AssetDetail],
    [AS_NME_ChangedAt],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability],
    [AS_GEO_Longitude_Deg],
    [AS_GEO_Latitude_Deg],
    [AS_GEO_ChangedAt],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability],
    [ROW_ID]
    SELECT
    COALESCE([i].[AS_PositedBy], @PositedBy),
    COALESCE([i].[AS_PositedAt], @Now),
    [i].[AS_NME_AssetTag],
    [i].[AS_NME_AssetName],
    [i].[AS_NME_AssetDetail],
    COALESCE([i].[AS_NME_ChangedAt], @Now),
    COALESCE([i].[AS_NME_PositedBy], @PositedBy),
    COALESCE([i].[AS_NME_PositedAt], @Now),
    COALESCE([i].[AS_NME_PositReliability], @Reliability),
    [i].[AS_GEO_Longitude_Deg],
    [i].[AS_GEO_Latitude_Deg],
    COALESCE([i].[AS_GEO_ChangedAt], @Now),
    COALESCE([i].[AS_GEO_PositedBy], @PositedBy),
    COALESCE([i].[AS_GEO_PositedAt], @Now),
    COALESCE([i].[AS_GEO_PositReliability], @Reliability),
    ROW_NUMBER() OVER (PARTITION BY [i].[AS_ID] ORDER BY [i].[AS_ID])
    FROM
    [inserted] [i]
    LEFT OUTER JOIN
    [org].[AS_Assets_Current] [c]
    ON [c].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag], [i].[AS_NME_AssetName], [i].[AS_NME_AssetDetail])
    WHERE
    [i].[AS_ID] IS NULL
    AND [i].[AS_NME_ID] IS NULL
    AND [i].[AS_NME_AS_ID] IS NULL
    AND [i].[AS_GEO_ID] IS NULL
    AND [i].[AS_GEO_AS_ID] IS NULL
    AND [c].[AS_NME_AS_ID] IS NULL;
    DECLARE @Anchor TABLE
    [ROW_ID] INT NOT NULL IDENTITY(1, 1),
    [AS_ID] INT NOT NULL,
    PRIMARY KEY([ROW_ID] ASC),
    UNIQUE CLUSTERED([AS_ID] ASC)
    INSERT INTO [org].[AS_Assets]
    [AS_PositedBy],
    [AS_PositedAt]
    OUTPUT
    [inserted].[AS_ID]
    INTO
    @Anchor
    [AS_ID]
    SELECT
    [i].[AS_PositedBy],
    [i].[AS_PositedAt]
    FROM
    @Inserted [i]
    ORDER BY
    [i].[ROW_ID] ASC;
    DECLARE @NME_Posit TABLE
    [AS_NME_ID] INT NOT NULL,
    [AS_NME_Checksum] INT NOT NULL,
    PRIMARY KEY([AS_NME_ID] ASC),
    UNIQUE CLUSTERED([AS_NME_Checksum] ASC)
    INSERT INTO [org].[AS_NME_Assets_Name_Posit]
    [AS_NME_AS_ID],
    [AS_NME_AssetTag],
    [AS_NME_AssetName],
    [AS_NME_AssetDetail],
    [AS_NME_ChangedAt]
    OUTPUT
    [inserted].[AS_NME_ID],
    [inserted].[AS_NME_Checksum]
    INTO
    @NME_Posit
    [AS_NME_ID],
    [AS_NME_Checksum]
    SELECT
    [a].[AS_ID],
    [i].[AS_NME_AssetTag],
    [i].[AS_NME_AssetName],
    [i].[AS_NME_AssetDetail],
    [i].[AS_NME_ChangedAt]
    FROM
    @Inserted [i]
    LEFT OUTER JOIN
    @Anchor [a]
    ON [a].[ROW_ID] = [i].[ROW_ID]
    WHERE [a].[AS_ID] IS NOT NULL;
    INSERT INTO [org].[AS_NME_Assets_Name_Annex]
    [AS_NME_ID],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability]
    SELECT
    [p].[AS_NME_ID],
    [i].[AS_NME_PositedBy],
    [i].[AS_NME_PositedAt],
    [i].[AS_NME_PositReliability]
    FROM
    @Inserted [i]
    INNER JOIN
    @NME_Posit [p]
    ON [p].[AS_NME_Checksum] = [i].[AS_NME_Checksum];
    DECLARE @GEO_Posit TABLE
    [AS_GEO_ID] INT NOT NULL,
    [AS_GEO_Checksum] INT NOT NULL,
    PRIMARY KEY([AS_GEO_ID] ASC),
    UNIQUE CLUSTERED([AS_GEO_Checksum] ASC)
    INSERT INTO [org].[AS_GEO_Assets_Location_Posit]
    [AS_GEO_AS_ID],
    [AS_GEO_Longitude_Deg],
    [AS_GEO_Latitude_Deg],
    [AS_GEO_ChangedAt]
    OUTPUT
    [inserted].[AS_GEO_ID],
    [inserted].[AS_GEO_Checksum]
    INTO
    @GEO_Posit
    [AS_GEO_ID],
    [AS_GEO_Checksum]
    SELECT
    [a].[AS_ID],
    [i].[AS_GEO_Longitude_Deg],
    [i].[AS_GEO_Latitude_Deg],
    [i].[AS_NME_ChangedAt]
    FROM
    @Inserted [i]
    LEFT OUTER JOIN
    @Anchor [a]
    ON [a].[ROW_ID] = [i].[ROW_ID]
    WHERE [a].[AS_ID] IS NOT NULL
    AND [i].[AS_GEO_Longitude_Deg] IS NOT NULL
    AND [i].[AS_GEO_Latitude_Deg] IS NOT NULL;
    INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
    [AS_GEO_ID],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability]
    SELECT
    [p].[AS_GEO_ID],
    [i].[AS_GEO_PositedBy],
    [i].[AS_GEO_PositedAt],
    [i].[AS_GEO_PositReliability]
    FROM
    @Inserted [i]
    INNER JOIN
    @GEO_Posit [p]
    ON [p].[AS_GEO_Checksum] = [i].[AS_GEO_Checksum];
    END;
    GO
    CREATE TRIGGER [org].[AS_Assets_Current_Update]
    ON [org].[AS_Assets_Current]
    INSTEAD OF UPDATE
    AS
    BEGIN
    SET NOCOUNT ON;
    SET XACT_ABORT ON;
    IF(UPDATE([AS_ID]))
    RAISERROR('Cannot update the anchor identity column ''AS_ID''.', 16, 1);
    IF(UPDATE([AS_PositedBy]))
    RAISERROR('Cannot update the anchor column ''AS_PositedBy''.', 16, 1);
    IF(UPDATE([AS_PositedAt]))
    RAISERROR('Cannot update the anchor column ''AS_PositedAt''.', 16, 1);
    IF(UPDATE([AS_NME_ID]))
    RAISERROR('Cannot update the identity column ''AS_NME_ID''.', 16, 1);
    IF(UPDATE([AS_NME_AS_ID]))
    RAISERROR('Cannot update the foreign key identity column ''AS_NME_AS_ID''.', 16, 1);
    IF(UPDATE([AS_NME_Checksum]))
    RAISERROR('Cannot update the computed column ''AS_NME_Checksum''.', 16, 1);
    IF(UPDATE([AS_NME_PositReliable]))
    RAISERROR('Cannot update the computed column ''AS_NME_PositReliable''.', 16, 1);
    IF(UPDATE([AS_GEO_ID]))
    RAISERROR('Cannot update the identity column ''AS_GEO_ID''.', 16, 1);
    IF(UPDATE([AS_GEO_AS_ID]))
    RAISERROR('Cannot update the foreign key identity column ''AS_GEO_AS_ID''.', 16, 1);
    IF(UPDATE([AS_GEO_Checksum]))
    RAISERROR('Cannot update the computed column ''AS_GEO_Checksum''.', 16, 1);
    IF(UPDATE([AS_GEO_PositReliable]))
    RAISERROR('Cannot update the computed column ''AS_GEO_PositReliable''.', 16, 1);
    IF(UPDATE([AS_GEO_Wgs84]))
    RAISERROR('Cannot update the computed column ''AS_GEO_Wgs84''.', 16, 1);
    DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
    DECLARE @PositedBy INT;
    EXECUTE @PositedBy = [posit].[Return_PositorId];
    DECLARE @Inserted TABLE
    [AS_ID] INT NOT NULL,
    [AS_PositedBy] INT NOT NULL,
    [AS_PositedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_ID] INT NOT NULL,
    [AS_NME_AS_ID] INT NOT NULL,
    [AS_NME_AssetTag] VARCHAR(12) NULL CHECK([AS_NME_AssetTag] <> ''),
    [AS_NME_AssetName] NVARCHAR(24) NULL CHECK([AS_NME_AssetName] <> ''),
    [AS_NME_AssetDetail] NVARCHAR(48) NULL CHECK([AS_NME_AssetDetail] <> ''),
    [AS_NME_Checksum] AS BINARY_CHECKSUM([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail])
    PERSISTED NOT NULL,
    [AS_NME_ChangedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_PositedBy] INT NOT NULL,
    [AS_NME_PositedAt] DATETIMEOFFSET(7) NOT NULL,
    [AS_NME_PositReliability] TINYINT NOT NULL,
    [AS_GEO_ID] INT NULL,
    [AS_GEO_AS_ID] INT NULL,
    [AS_GEO_Longitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Longitude_Deg] >= -180.0), CHECK([AS_GEO_Longitude_Deg] <= 180.0),
    [AS_GEO_Latitude_Deg] DECIMAL(17, 14) NULL CHECK([AS_GEO_Latitude_Deg] >= -90.0), CHECK([AS_GEO_Latitude_Deg] <= 90.0),
    [AS_GEO_Checksum] AS BINARY_CHECKSUM([AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg])
    PERSISTED NOT NULL,
    [AS_GEO_ChangedAt] DATETIMEOFFSET(7) NULL,
    [AS_GEO_PositedBy] INT NULL,
    [AS_GEO_PositedAt] DATETIMEOFFSET(7) NULL,
    [AS_GEO_PositReliability] TINYINT NULL,
    [ROW_ID] INT NOT NULL,
    PRIMARY KEY([ROW_ID] ASC)
    INSERT INTO @Inserted
    [AS_ID],
    [AS_PositedBy],
    [AS_PositedAt],
    [AS_NME_ID],
    [AS_NME_AS_ID],
    [AS_NME_AssetTag],
    [AS_NME_AssetName],
    [AS_NME_AssetDetail],
    [AS_NME_ChangedAt],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability],
    [AS_GEO_ID],
    [AS_GEO_AS_ID],
    [AS_GEO_Longitude_Deg],
    [AS_GEO_Latitude_Deg],
    [AS_GEO_ChangedAt],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability],
    [ROW_ID]
    SELECT
    [i].[AS_ID],
    CASE WHEN (UPDATE([AS_PositedBy])) THEN [i].[AS_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_PositedAt])) THEN [i].[AS_PositedAt] ELSE @Now END,
    [i].[AS_NME_ID],
    [i].[AS_NME_AS_ID],
    [i].[AS_NME_AssetTag],
    [i].[AS_NME_AssetName],
    [i].[AS_NME_AssetDetail],
    CASE WHEN (UPDATE([AS_NME_ChangedAt])) THEN [i].[AS_NME_ChangedAt] ELSE @Now END,
    CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
    [i].[AS_NME_PositReliability],
    [i].[AS_GEO_ID],
    [i].[AS_GEO_AS_ID],
    [i].[AS_GEO_Longitude_Deg],
    [i].[AS_GEO_Latitude_Deg],
    CASE WHEN (UPDATE([AS_GEO_ChangedAt])) THEN [i].[AS_GEO_ChangedAt] ELSE @Now END,
    CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
    [i].[AS_GEO_PositReliability],
    ROW_NUMBER() OVER (PARTITION BY [i].[AS_ID] ORDER BY [i].[AS_ID])
    FROM
    [inserted] [i]
    LEFT OUTER JOIN
    [org].[AS_Assets_Current] [c]
    ON [c].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag], [i].[AS_NME_AssetName], [i].[AS_NME_AssetDetail])
    LEFT OUTER JOIN
    [org].[AS_Assets_Current] [g]
    ON [g].[AS_GEO_Checksum] = BINARY_CHECKSUM([i].[AS_GEO_Longitude_Deg], [i].[AS_GEO_Latitude_Deg])
    WHERE
    [c].[AS_NME_AS_ID] IS NULL
    OR [g].[AS_NME_AS_ID] IS NULL;
    DECLARE @NME_Posit TABLE
    [AS_NME_ID] INT NOT NULL,
    [AS_NME_Checksum] INT NOT NULL,
    PRIMARY KEY([AS_NME_ID] ASC),
    UNIQUE CLUSTERED([AS_NME_Checksum] ASC)
    INSERT INTO [org].[AS_NME_Assets_Name_Posit]
    [AS_NME_AS_ID],
    [AS_NME_AssetTag],
    [AS_NME_AssetName],
    [AS_NME_AssetDetail],
    [AS_NME_ChangedAt]
    OUTPUT
    [inserted].[AS_NME_ID],
    [inserted].[AS_NME_Checksum]
    INTO
    @NME_Posit
    [AS_NME_ID],
    [AS_NME_Checksum]
    SELECT
    [i].[AS_NME_AS_ID],
    [i].[AS_NME_AssetTag],
    [i].[AS_NME_AssetName],
    [i].[AS_NME_AssetDetail],
    [i].[AS_NME_ChangedAt]
    FROM @Inserted [i];
    INSERT INTO [org].[AS_NME_Assets_Name_Annex]
    [AS_NME_ID],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability]
    SELECT
    [p].[AS_NME_ID],
    CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
    [i].[AS_NME_PositReliability]
    FROM @Inserted [i]
    INNER JOIN
    @NME_Posit [p]
    ON [p].[AS_NME_Checksum] = [i].[AS_NME_Checksum];
    INSERT INTO [org].[AS_NME_Assets_Name_Annex]
    [AS_NME_ID],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability]
    SELECT
    [i].[AS_NME_ID],
    CASE WHEN (UPDATE([AS_NME_PositedBy])) THEN [i].[AS_NME_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_NME_PositedAt])) THEN [i].[AS_NME_PositedAt] ELSE @Now END,
    [i].[AS_NME_PositReliability]
    FROM [inserted] [i]
    LEFT OUTER JOIN
    @NME_Posit [p]
    ON [p].[AS_NME_Checksum] = BINARY_CHECKSUM([i].[AS_NME_AssetTag])
    WHERE
    [p].[AS_NME_ID] IS NULL;
    DECLARE @GEO_Posit TABLE
    [AS_GEO_ID] INT NOT NULL,
    [AS_GEO_Checksum] INT NOT NULL,
    PRIMARY KEY([AS_GEO_ID] ASC),
    UNIQUE CLUSTERED([AS_GEO_Checksum] ASC)
    INSERT INTO [org].[AS_GEO_Assets_Location_Posit]
    [AS_GEO_AS_ID],
    [AS_GEO_Longitude_Deg],
    [AS_GEO_Latitude_Deg],
    [AS_GEO_ChangedAt]
    OUTPUT
    [inserted].[AS_GEO_ID],
    [inserted].[AS_GEO_Checksum]
    INTO
    @GEO_Posit
    [AS_GEO_ID],
    [AS_GEO_Checksum]
    SELECT
    [i].[AS_GEO_AS_ID],
    [i].[AS_GEO_Longitude_Deg],
    [i].[AS_GEO_Latitude_Deg],
    [i].[AS_GEO_ChangedAt]
    FROM @Inserted [i];
    INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
    [AS_GEO_ID],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability]
    SELECT
    [p].[AS_GEO_ID],
    CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
    [i].[AS_GEO_PositReliability]
    FROM @Inserted [i]
    INNER JOIN
    @GEO_Posit [p]
    ON [p].[AS_GEO_Checksum] = [i].[AS_GEO_Checksum];
    INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
    [AS_GEO_ID],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability]
    SELECT
    [i].[AS_GEO_ID],
    CASE WHEN (UPDATE([AS_GEO_PositedBy])) THEN [i].[AS_GEO_PositedBy] ELSE @PositedBy END,
    CASE WHEN (UPDATE([AS_GEO_PositedAt])) THEN [i].[AS_GEO_PositedAt] ELSE @Now END,
    [i].[AS_GEO_PositReliability]
    FROM [inserted] [i]
    LEFT OUTER JOIN
    @GEO_Posit [p]
    ON [p].[AS_GEO_Checksum] = BINARY_CHECKSUM([i].[AS_GEO_Longitude_Deg], [i].[AS_GEO_Latitude_Deg])
    WHERE
    [p].[AS_GEO_ID] IS NULL;
    END;
    GO
    CREATE TRIGGER [org].[AS_Assets_Current_Delete]
    ON [org].[AS_Assets_Current]
    INSTEAD OF DELETE
    AS
    BEGIN
    SET NOCOUNT ON;
    DECLARE @Now DATETIMEOFFSET(7) = SYSDATETIMEOFFSET();
    DECLARE @PositedBy INT;
    EXECUTE @PositedBy = [posit].[Return_PositorId];
    INSERT INTO [org].[AS_NME_Assets_Name_Annex]
    [AS_NME_ID],
    [AS_NME_PositedBy],
    [AS_NME_PositedAt],
    [AS_NME_PositReliability]
    SELECT
    [d].[AS_NME_ID],
    @PositedBy,
    @Now,
    0
    FROM
    [deleted] [d];
    INSERT INTO [org].[AS_GEO_Assets_Location_Annex]
    [AS_GEO_ID],
    [AS_GEO_PositedBy],
    [AS_GEO_PositedAt],
    [AS_GEO_PositReliability]
    SELECT
    [d].[AS_GEO_ID],
    @PositedBy,
    @Now,
    0
    FROM
    [deleted] [d];
    END;
    GO
    INSERT INTO [org].[AS_Assets_Current]
    [AS].[AS_NME_AssetTag],
    [AS].[AS_NME_AssetName],
    [AS].[AS_NME_AssetDetail],
    [AS].[AS_GEO_Longitude_Deg],
    [AS].[AS_GEO_Latitude_Deg]
    SELECT
    [AS].[AS_NME_AssetTag],
    [AS].[AS_NME_AssetName],
    [AS].[AS_NME_AssetDetail],
    [AS].[AS_GEO_Longitude_Deg],
    [AS].[AS_GEO_Latitude_Deg]
    FROM (VALUES
    ('999', 'Dallas Test 3', 'Dallas Test 3', NULL, NULL, 'Plant', 'AUT', NULL)
    ) [AS]([AS_NME_AssetTag], [AS_NME_AssetName], [AS_NME_AssetDetail], [AS_GEO_Longitude_Deg], [AS_GEO_Latitude_Deg], [CN_ADD_Type_ID], [CN_ADD_Country_ID], [CN_ADD_State]);
    GO

  • What is difference of truncate/insert and delete/insert ?

    hi all:
    what is difference of truncate/insert and delete/insert ?

    Hi,
    Truncate will truncate the table, which means there is a DDL operation to empty the table. DDL operations cannot be rolled back, but truncate is much faster than delete (because of that reason). If you do not require recovery of the deleted records in case of a failure, then truncate/insert is more optimal than delete/insert. Notice that for truncate to work, you cannot have enabled foreign keys pointing to the table. Truncate will never perform cascaded deletes.
    Hope this explains.
    Mark.

  • Insert Icon and Insert Menu javascript out of memory error message

    Every time I hit the insert menu to insert a table, photo, etc, I get an error message that says Javascript out of memory.  This happens when I try to insert a table using the table icons too.  How can I fix this?

    Try this KB article:
    http://kb2.adobe.com/cps/405/kb405604.html

  • Insert All and  Insert

    Hi All,
    Please help to elaborate the difference between Insert All and Insert in oracle 10g.
    Thanks,
    regards,

    Make the documentation your friend and you'll seldom need to rely on others (removes latency :)
    [http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#SQLRF01604]

  • In jdbc adapter what is the difference between insert and update insert

    in jdbc adapter what is the difference between insert and update insert
    Edited by: katru vijay on Mar 22, 2010 7:43 AM

    Please refer to this Link [Document Formats for the Receiver JDBC Adapter|http://help.sap.com/saphelp_nw04/Helpdata/EN/22/b4d13b633f7748b4d34f3191529946/frameset.htm]
    Hope this helps.
    Regards,
    Chandravadan

  • Open pdf document from local disk on button trigger from Oracle form in 6i

    hi all.
    i have an application in oracle forms 6i. The system from where forms are run...has a local folder with pdf documents. the requirement is that when user click on a button in oracle form...the respective pdf from the local folder should open (in browser or in adobe pdf or in any other way).
    I really desperately need this help. had googled. did use the host and client_host commands in the button trigger but am presented with error "host, client_host" not declared.
    bundles of thanks in advance for getting me out of this.

    Hi
         DECLARE
         pl_dept paramlist;
         com_code varchar2(1);
         BEGIN
         pl_dept := Get_Parameter_List('tmpdata');
         IF NOT Id_Null(pl_dept) THEN
              Destroy_Parameter_List( pl_dept );
         END IF;
         pl_dept := Create_Parameter_List('tmpdata');
            ADD_PARAMETER(pl_dept,'p_date_from',TEXT_PARAMETER,:date_from);
            ADD_PARAMETER(pl_dept,'p_date_to',TEXT_PARAMETER,:date_to);
            ADD_PARAMETER(pl_dept,'destype',text_parameter,'file');
            ADD_PARAMETER(pl_dept,'DESFORMAT',TEXT_PARAMETER,'pdf');
         Add_Parameter(pl_dept,'paramform',TEXT_PARAMETER,'NO');
         Run_Product(REPORTS, 'EMP_STATISTIC_REP.rep', SYNCHRONOUS, RUNTIME,FILESYSTEM, pl_dept,NULL);
    End;      Not tested hope it works...
    Regards,
    Amatu Allah

Maybe you are looking for

  • IMac will not boot up?? Help please!

    Hi, I have a 24" Imac which is around 16 months old. Yesterday I was surfing on the net, when suddenly the screen darkened, like a curtain falling down from top to bottom. You could still see the screen but the desktop was now darker. Also a black bo

  • My HDV camera is recognised, but no image or data appears in log window?

    I'm trying to download footage from my Sony HDV camera. FCStudio recognises the camera, device control works, but no data or image appears in the log and capture window. I've reinstalled FCP, trashed preferences, still doesn't work. Help please...

  • Flash Newbie Question

    I have two animations on a single web page (in different locations). One animation starts as soon as the page is loaded and I have inserted a stop action to halt it after one loop. I have a second animation on the page that I would like to start auto

  • I have Problems with starting em dbconsole after a fresh Installation

    I have been having problems running EM console on Oracle 10g R2 on windows xp after a fresh installation and I did not receive any error messages while the Installation was going on. I was able to log into sqlplus successfully and I started the insta

  • AHHH!!! Printer driving me nuts, please help!

    I have a IMac running OS10.4.10, and a Brother laser printer. They all previously worked perfectly until recently. Can not remember what I changed at all, except for installing an component to Quick Time to play Windows media player files. 1. Printer