GDS: Material not inserted into repository

Hi all,
When trying to load a material from our ERP system into the GDS
repository (via XI and the JavaProxy call), we notice an increased load
on the MDM server, but the material does not show up in the repository.
Neither in the MDM logs, nor in the defaultTrace or application log of
the GDS Console, an error (or any other entry) is logged.
We can access the repository from the GDS Console, though. Creating
materials for testing purposes from within the UI works.
We're using MDM 5.5 SP04 Patch03 (5.5.35.15) and GDS 1.0 SP05 Patch01.
As a precaution, we've removed the password from the user "Admin" of
the GDS repository. Does someone know whether this is a prerequisite?
Kind regards,
Dennis

Hi,
I am facing same problem. Do you know what is the solution ?
Thanks
Reddi

Similar Messages

  • File to RFC problem- data is not inserting into ztable in R3 system

    Hi
    i have done File to RFC scenario which picks data from flat file and inserts into ztable via RFC in R3. but while testing my scenario everything is successful in XI monitoring (Successful flag in MONI and RWB) and in auditlog message status is DLVD.
    it seems to be everything successful in XI and RFC call also successful in R3 system.
    but for some reason data is not inserting into table (RFC is used to insert data into ztable)
    Is there any way to debug RFC call excecution in XI..?
    RFC code is like this:
    insert ZMM_AUTO_GR from INPUT_TABLE.
    commit work.
    END FUNCTION.
    please advice what could be the reason not inserting into table.
    Help would be appreciated.
    Regards,
    Rajesh

    Hi Praveen,
    please see audit log- from communication channel monitoring..
    Receiver channel 'CC_INCA_RFC_SAPECC_Receiver' for party '', service 'R3DCLNT210' (internal name 'RfcClient[CC_INCA_RFC_SAPECC_Receiver]')
    Client data: {jco.client.lang=EN, jco.client.snc_mode=0, jco.client.client=210, jco.client.passwd=******, jco.webas.ignore_jdsr_error=1, jco.client.user=jsaha, jco.client.sysnr=00, jco.client.ashost=ausr3devdc02}
    Repository data: {jco.client.lang=EN, jco.client.snc_mode=0, jco.client.client=210, jco.client.passwd=******, jco.webas.ignore_jdsr_error=1, jco.client.user=jsaha, jco.client.sysnr=00, jco.client.ashost=ausr3devdc02}
    Current pool size: 1, maximum pool size : 1
    Channel History
    - OK: 2008-07-28 04:32:04 PDT: Message processed for interface ZAUTO_GR_STAGE_INCA
    - OK: 2008-07-28 04:31:04 PDT: Message processed for interface ZAUTO_GR_STAGE_INCA
    - OK: 2008-07-28 03:56:56 PDT: Message processed for interface ZAUTO_GR_STAGE_INCA
    - OK: 2008-07-28 03:49:04 PDT: Message processed for interface ZAUTO_GR_STAGE_INCA
    - OK: 2008-07-28 03:48:04 PDT: Message processed for interface ZAUTO_GR_STAGE_INCA

  • Record not inserting into the table through Forms 10g

    Hi all,
    I have created a form in 10g(10.1.2.0.2) based on just one table that has 4 columns(col1, col2, col3, col4).
    Here col1, col2 and col3 are VARCHAR2 and col4 is date and all the columns are not null columns(There are no primary and foriegn key constrains, which means duplicates are allowed).
    My form contains 2 blocks where block 1 has one text item (col1) and 3 buttons (Delete, Save, Exit).
    And block2 is a database block and has col2,col3,col4 which are in tabluar layout frame displaying 10 records.
    When the form is opened the cursor has to be in block1.col1 for querrying. Here i enter a value in col1, and then when I click on col2 in the block2, then I put execute_query in new_block_instance of block2, which displays the records.
    The block2 properties are not updatable, insertable and query is allowed.
    Everything is working good until here. But here in the block2 when I want to insert another record into the table, by navigating all the way down to the last empty record and entering the new values for col2, col3 and col4 And then Ctrl+S will display the message "*FRM-40400: Transaction complete: 1 record applied and saved.*" But actually the record is not inserted into the table.
    I also disabled the col4 by setting the Enabled property to No, since while inserting new record the date have to be populated into it and it shouldnt be changed by the user. And im populating the sysdate into the new record by setting Intial Value property to *$$DATE$$*.
    And another requirement which I could not work arround here is that, the col3 also should be populated with the username of the user while inserting.
    please help me...

    Hi Sarah,
    I do not want to update the existing record. So I kept Udate Allowed to No in property palette for the items in block2.
    Do I have to do this property at block level also?
    I'm inserting a new record here.
    Edited by: Charan on Sep 19, 2011 8:48 AM

  • I purchased the Logitech F310 game controller for my 2011 MacBook Pro. How do I get the driver installed for it. The Disk that came with the controller is a mini disk and will not insert into my laptop.

    I purchased the Logitech F310 game controller for my 2011 MacBook Pro. How do I get the driver installed for it. The Disk that came with the controller is a mini disk and will not insert into my laptop.

    May not make a difference anyway. The Logitech support site does not show drivers for Mac OS for the F310:
    http://www.logitech.com/en-us/support/gamepad-f310?crid=411
    I'd contact their support to find out if there is a Mac driver available, and if they can either give you a web link to get it, e-mail you the software, or snail-mail you a standard-size disk with the drivers.

  • Records are not inserted into MTL_TXN_REQUEST_HEADERS,MTL_TXN_REQUEST_LINES

    Hi all,
    I am doing pick release thru API.
    For that , I have run following API successfully but my problem is that records are not inserted into MTL_TXN_REQUEST_HEADERS , MTL_TXN_REQUEST_LINES
    tables so that I cannot generate the move order. Can anyone suggent the valuable tips for that ?
    1. WSH_DELIVERIES_PUB.create_update_delivery
    2. WSH_DELIVERY_DETAILS_PUB.Detail_to_Delivery
    3. WSH_PICKING_BATCHES_PUB.CREATE_BATCH
    4. WSH_PICKING_BATCHES_PUB.RELEASE_BATCH
    5. WSH_DELIVERIES_PUB.Delivery_Action ( for p_action_code = 'PICK-RELEASE' )
    regards with thanks in advance
    sanjay

    Hi All,
    To create a Move Order Header & Line Record in MTL_TXN_REQUEST_HEADERS and MTL_TXN_REQUEST_LINES tables , I have run an seeded
    procedure : CreateMoveOrderHeader & CreateMoveOrderLines .
    The procedure : CreateMoveOrderHeader was run successfully but when I am going to run procedure : CreateMoveOrderLines , it is giving
    an error .
    Following Error text I am receiving at the time of running of procedure : CreateMoveOrderLines .
    Initialized applications context: 5707 50138 660
    *==========================================================*
    Calling INV_MOVE_ORDER_PUB.Create_Move_Order_Lines API
    *==========================================================*
    Return Status: E
    Error Message :INV
    *==========================================================*
    From the above error message, no specific error is received . Only " Error Message : INV " is received hence it is very difficult to judge & resolve an error .
    Can anyone guide me that what is an error ? For what reason I am getting an error ?
    regrads
    Sanjay

  • Data is not inserting into table

    Hi Team,
    I am inserting data into a custom table.
    but my records are not inserting into table
    //CO File
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    am.invokeMethod("createEmployee");
    // am.invokeMethod("init");
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (pageContext.getParameter("Apply") != null)
    OAViewObject vo = (OAViewObject)am.findViewObject("TestEmpVO1");
    String NAME = (String)vo.getCurrentRow().getAttribute("Name");
    Number employeeNumber = (Number)vo.getCurrentRow().getAttribute("Num");
    String NUM = String.valueOf(employeeNumber.intValue());
    am.invokeMethod("apply");
    MessageToken[] tokens = { new MessageToken("EMP_NAME", NAME),
    new MessageToken("EMP_NUMBER", NUM) };
    OAException confirmMessage = new OAException("AK", "FWK_TBX_T_EMP_CREATE_CONFIRM", tokens,
    OAException.CONFIRMATION, null);
    pageContext.putDialogMessage(confirmMessage);
    else if (pageContext.getParameter("Cancel") != null)
    am.invokeMethod("rollbackEmployee");
    TransactionUnitHelper.endTransactionUnit(pageContext, "empCreateTxn");
    // End CO
    //AMImpl
    package oracle.apps.fnd.framework.toolbox.labsolutions.server;
    import oracle.jbo.Row;
    import oracle.jbo.Transaction;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.OARow;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.apps.fnd.framework.server.OAViewObjectImpl;
    // --- File generated by Oracle Business Components for Java.
    public class TestEmpAMImpl extends EmployeeAMImpl
    * This is the default constructor (do not remove)
    public TestEmpAMImpl()
    * Container's getter for TestEmpVO1
    public TestEmpVOImpl getTestEmpVO1()
    return (TestEmpVOImpl)findViewObject("TestEmpVO1");
    * Creates a new employee.
    public void createEmployee()
    OAViewObject vo = (OAViewObject)getTestEmpVO1();
    // Per the coding standards, this is the proper way to initialize a
    // VO that is used for both inserts and queries. See View Objects
    // in Detail in the Developer's Guide for additional information.
    if (!vo.isPreparedForExecution())
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    // Required per OA Framework Model Coding Standard M69
    row.setNewRowState(Row.STATUS_INITIALIZED);
    } // end createEmployee()
    public void apply()
    getDBTransaction().commit();
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("oracle.apps.fnd.framework.toolbox.labsolutions.server", "TestEmpAMLocal");
    //End AmImpl
    Please suggest.
    Thanks,
    Ajit

    Ajit,
    Its always a good idea to close the thread with an explanation. It will help others whenever they are into similar situation.
    --Shiv                                                                                                                                                                                                                                                                                               

  • Popup not INSERTing into table and not refreshing called page ...

    Greetings
    Environment: APEX 3.1.1.00.09 on AIX 5.3 in 10gR2
    I have read many of the threads concerning my issue and I feel I am getting close to the answer but somehow have combined too many of the suggestions and am tripping over my own code.
    Please look at my sample application on apex.oracle.com:
    Workspace: galway
    User: gwicke
    Password: gwicke
    Please start with Page3, select any Agency and then click 'Add New Contract'.
    There is currently a <strong>BOLD </strong>label 'Add New Builder' that is a link that should open a popup window. Type any name into the field and click 'Create Builder'. This should INSERT the row into the builder table, close the popup, assign the new builder name to the calling page item 'Builder Name' and populate the screen item.
    In it's current state, the application will open the popup window, allow entry and close upon clicking the 'Create Builder' button. However the new builder is NOT inserted into the table and the calling page item is not populated.
    By looking at the Page Items and Session State I can see the correct values assigned to the 'Pn_BULDER_NAME' items on both the popup page (4) and the calling page (2) but the value does not appear on the screen.
    I've read where there's really two parallel universes, no sorry, two versions of the screen items, one in Session State and one that is displayed in the browser and there are steps to take to be sure the one displayed is updated from Session State as I would like in this case.
    I've entered Javascript code in the Page4 - header to define the 'passBack2()' function and code in the 'Optional URL Redirect' section of the 'Add Builder' button to hopefully execute the ARP for the INSERT, assign the Page2 items and close the popup. It doesn't quite get all that done.
    Any helpp is greatly appreciated. Thanks to Denes for most of the code suggestions I've followed.
    -gary

    Hi Gary,
    I think that there's a very simple solution to this - didn't really spot it last night.
    Firstly, yes, you could use a "button" to handle the call for the popup - just make sure that the button is a URL type "button" that is actually an A tag with the call in the URL target setting. Alternatively, you could take you existing A tag and use the same class attribute for one of your buttons as this should make it look like a button.
    More importantly, though, I think that we could do it as:
    1 - On your page 2 popup call, clear that cache for page 4 (the popup page) - I have already done this in your app by updating the url
    2 - On the popup page, allow the user to enter in their desired P4_BUILDER_NAME value (not sure if you want to do something to make this unique?)
    3 - Let the user click the Create button on the popup. This will submit the page, which will get your P4_BUILDER_RANK (the pk) value and insert a new record into the table (you could consider creating a sequence and a trigger to handle the creation of a new PK value?).
    4 - Assuming the P4_BUILDER_RANK then exists (it wouldn't if there was an error somewhere), then conditionally display a region that had a piece of javascript that submits page 2 and then closes itself - we don't need to pass anything back to page 2 (see below)
    5 - As the P4_BUILDER_NAME and P4_BUILDER_RANK exist in the session, when page 2 is being reloaded, (A) the select list would be updated with the new Builder (still not sure why all my entries appeared at the bottom instead of in alpha order??) and (B) both P2_BUILDER_NAME and P2_BUILDER_RANK can have Post Calculation Computations set (NVL(:P4_BUILDER_NAME,:P2_BUILDER_NAME) and NVL(:P4_BUILDER_RANK, :P2_BUILDER_RANK) respectively) - the effect of this is, if there are values stored in the P4 page items, we use them, otherwise we use whatever values were in the P2 page items
    6 - Finally, to stop (5) happening in all page 2 loads, you would need to clear the cache for page 4 in as many places as possible - eg, branches to page 2 or buttons on page 2
    The reason we can't pass values back to page 2 is that one of the items is a select list. The value we want to select won't appear on the select list until the page has been submitted. So, we can't set the value and submit because the value isn't there. We can't submit and set the value because javascript wouldn't know when the page has been updated (or, at least, you would have to put some independant mechanism in place to identify this, which may become complicated).
    So, simply put, as long as we know that if the values are in the session, we can use Post Calculation Computations to set our fields to these values. The only thing to bear in mind is that we need to ensure that these session values only exist when we need them - hence clearing the cache. This principle should work for any type of field - but, as you have no doubt seen, simple text fields can be updated by the popup directly as the field should accept any value we give it.
    My only other recommendation would be to completely remove the MRU processes from the page as these are not required (they just confuse the issue) and you could make your PK fetch and record insert into a single process - just to keep things neat and tidy, you understand!
    When I finished with your app last night, I did leave it so that javascript would create a new option on the select list and then set the value. But the above methodology seems to be a lot simpler.
    Andy

  • CK11N  Follow-up material not taken into account when costing

    We are running the standard cost with quantity structure and we have detected that all the follow-up information is not taken into account to determine the bill of materials that will be used to calculate the standard cost.
    SAP helpdesk has answered me the following:
    "The situation in product cost planning is we do not check availability of any material stocks, and therefore we cannot provide the same functionality as MRP. You will have to create a new BOM that includes
    the follow-up material or apply the modification to take into account the follow-up part."
    Please, if anyone knows any user-exit we could use to develop something to fix it, we would appreciate it very much. It is a normal process and we can not say it does not work.
    Regards, and waiting for any solution.
    Yolanda.

    Dear,
    Are you getting these reservation in MD04?
    Check the Planning file entry for these material in MD21 if not then create it through MD20 and take MRP run with planning mode -3 Deleted and recreated. And Processing key NETCH.
    Also check the The firmed receipt is within the rescheduling horizon. The rescheduling horizon is set in Customizing for the MRP group (Transaction OPPR, Table T438M). A default value can be predefined in the Customizing of plant data (Transaction OPPQ, Table T399D). define the longer duration for it.
    The firmed receipt (the MRP element) participates in the rescheduling check. You can set which MRP elements participate in the rescheduling check in the Customizing of the plant data (Transaction OPPQ).
    Else you can carry out modification A using the MD_CHANGE_MRP_DATA BAdI and the CONSIDER_RESB method without making a modification.
    Regards,
    R.Brahmankar

  • Why I can not insert into a table?

    Hi, all,
    I have a table "personstudy" with records already. Its primary key is "subjectid". and I have added a new column named "personstatus" varchar2(20) to it. After that, I want to insert into the field with "enrolled" for all records there. My script is like this:
    insert into personstudy (personstatus) values ('enrolled');
    the system reports:
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("FLOWLIMS"."PERSONSTUDY"."SUBJECTID")
    I just can not understand it. Is there any wrong with my script?
    Thank you!
    Qian

    maybe want you need is not insert a new rows but to update the existing records to have the 'enrolled' value put into the column personstatus.
      update personstudy
         set personstatus = 'enrolled';

  • Issue - data is not inserting into queue table

    Hi friends....i created a queue table & queue , started queue. while inserting number into queue, it is going fine. but , while browsing queue table, there is no data inserted into table. table is empty. i executed same script in another machine, it is working fine there.but, it is not working in my machine. i don't know why?.
    can anybody please help me to find out what will be the issue.
    these are the scripts i created........
    BEGIN
    DBMS_AQADM.CREATE_QUEUE_TABLE (
    queue_table => 'put_queue_table',
    queue_payload_type => 'sys.aq$_jms_text_message'
    END;
    anonymous block completed
    BEGIN
    DBMS_AQADM.CREATE_QUEUE (
    queue_name => 'QUALTY_QUEUE',
    queue_table => 'put_queue_table'
    DBMS_AQADM.START_QUEUE (
    queue_name => 'QUALTY_QUEUE'
    END;
    anonymous block completed
    DECLARE
    v_payload SYS.AQ$_JMS_TEXT_MESSAGE;
    v_enqueue_options dbms_aq.enqueue_options_t;
    v_message_properties dbms_aq.message_properties_t;
    v_message_handle RAW(16);
    v_text VARCHAR2(37);
    BEGIN
    v_text := to_char('157');
    v_payload := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
    v_payload.set_text(v_text);
    DBMS_AQ.ENQUEUE(
    queue_name => 'QUALTY_QUEUE',
    enqueue_options => v_enqueue_options,
    message_properties => v_message_properties,
    payload => v_payload,
    msgid => v_message_handle
    COMMIT;
    END;
    anonymous block completed

    Please define what you mean by "when browsing [the] queue table" and why you think what you are doing should be inserting new rows in the table. Also please post full version information.

  • Second record not inserting into ztable

    Hi All,
    I have designed z table with following fields.
    1) CONSULTANT
    2) MODULE_NAME
    3) CR_DATE
    4) ISSUE
    5) RPT_NAME
    6) TCODE
    7) REQ_NO
    8) DEV_STA
    9) QA_STA
    10) PRD_STA.
    the ztable contains no primaty key as we are storing the duplicates values
    I have created One screen with all above fields using module pooled programming. One Input screen is designed containing all above fields. after that when i click on SAVE Button all above fields are getting inserted into ztable. But when i again fill the data the second record is not getting inserted into ztable.
    I have written the following code for this :
    wa_issue-CONSULTANT = ZISSUE-CONSULTANT.
    wa_issue-MODULE_NAME = ZISSUE-MODULE_NAME.
    wa_issue-CR_DATE = ZISSUE-CR_DATE.
    wa_issue-ISSUE = ZISSUE-ISSUE.
    wa_issue-RPT_NAME = ZISSUE-RPT_NAME.
    wa_issue-TCODE = ZISSUE-TCODe.
    wa_issue-REQ_NO = ZISSUE-REQ_NO.
    wa_issue-DEV_STA = ZISSUE-DEV_STA.
    wa_issue-QA_STA = ZISSUE-QA_STA.
    wa_issue-PRD_STA = ZISSUE-PRD_STA.
    insert into zissue values wa_issue .
    commit work.

    Hi,
    hcheck the key fields in the table
    Regards,
    V.Balaji
    Reward if Usefull...

  • Multi-table mapping is not inserting into the primary table first.

    I have an inheritance mapping where the children are mapped to the parent table oids with the "Multi-Table Info" tab.
    One of children is not inserting properly. Its insert is attempting to insert into one of the tables from the "Additional Tables" of "Multi-Table Info" instead of the primary table that it is mapped to.
    The other children insert correctly. This child is not much different from those.
    I looked through the forums, but found nothing similiar.

    I would expect the Children to be inserted into both the primary table and the Additional Table? Is the object in question inserted into the primary table at all? Is the problem that it is being inserted into the Additional Table first? If it is, are the primary key names different? Is it a foreign key relationship?
    If the object in question has no fields in the additional table is it mapped to the additional table? (it should not be)
    Perhaps providing the deployment XML will help determine the problem,
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Record not inserting into sap table with connector framework ?

    here is the code, but record not being inserting into the table ... but same piece of code working fine while updating ... the record ...
    try {
    interaction = connection.createInteractionEx();
    IInteractionSpec interactionSpec = interaction.getInteractionSpec();
    String functionName = "Z_XYZ";
    interactionSpec.setPropertyValue("Name", functionName);
    String writingTable = "MYTABLE";
    RecordFactory rf = interaction.getRecordFactory();
    MappedRecord importParams = rf.createMappedRecord("input");
    importParams.put("ATTR1", "VALUE1");
    importParams.put("ATTR2", "VALUE2");
    IFunction function = connection.getFunctionsMetaData().getFunction(functionName);
    IStructureFactory sf = interaction.retrieveStructureFactory();
    IRecordSet table = (IRecordSet) sf.getStructure(function.getParameter(writingTable).getStructure());
    table.insertRow();
    table.setString("ATNAME", "VALUE");
    table.setString("ATWRT", "VALUE");
    importParams.put(writingTable, table);
    MappedRecord output = (MappedRecord) interaction.execute(interactionSpec, importParams);
    } catch (Exception e) {
    any idea?
    than ks
    MMK

    Hi Mohan,
    Does a creation through SE37 with the same input work?
    Yoav.

  • Servlet not inserting into Access Databse. help please

    I have the following code which is inserting three fields into a database. The database name is contacts.mdb, and the table is contacts. I have setup the ODBC connection on the server, of which I have both IIS and Tomcat running. The form.html that I am accessing is on the tomcat server root and that code is below as well. After hitting the submit button on the form I get forwarded to the servlet, and the page is blank. However, when I open the database, no updates have occured. Please help. I hope I have provided enough detail. Thanks so much.
    -------- servlet code start --------------
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class WebServlet
    extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
    IOException {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = "jdbc:odbc:terry_web_contacts";
    Connection databaseConnection = DriverManager.getConnection(sourceURL);
    Statement stmt = databaseConnection.createStatement();
    String jname = request.getParameter("Name");
    String jemail = request.getParameter("Email");
    String jcomments = request.getParameter("Comments");
    String sqlInsertString ="INSERT INTO contacts (name, email, comments) VALUES ('" + jname +"', '" jemail "', '" + jcomments + "')";
    stmt.executeUpdate(sqlInsertString);
    databaseConnection.close();
    catch(ClassNotFoundException cnfe)
    System.err.println("Error loading Driver");
    catch (SQLException sqle){
    System.err.println("SQL Error");
    ---------- servlet code end ---------------------
    ---------- html form code start ------------------
    <HTML>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <BODY BGCOLOR="WHITE">
    <TABLE BORDER="2" CELLPADDING="2">
    <TR><TD WIDTH="275">
    <H2>I'm a Simple Form</H2>
    <FORM METHOD="POST" ACTION="/servlet/WebServlet">
    <p>
    <INPUT NAME="Name" TYPE="TEXT" id="Name" SIZE=30>
    </p>
    <p>
    <INPUT NAME="Email" TYPE="TEXT" id="Email" SIZE=30>
    </p>
    <p>
    <textarea name="Comments" id="Comments"></textarea>
    </p>
    <P>
    <INPUT TYPE="SUBMIT" VALUE="Click Me">
    <INPUT TYPE="RESET">
    </FORM>
    </TD></TR>
    </TABLE>
    </BODY>
    </HTML>
    ------------- html code end ------------------

    Okay, here is my modified code. However, I catch a sql error. It prints out "sql error". If I try to isolate the different lines of code with try catch blocks, the compiler says it does not recognize the symbols for example stmt, or databaseConnection. Arggh, what can I do? Help please.
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class WebServlet
        extends HttpServlet {
      public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException,IOException
         PrintWriter out = response.getWriter();
         String jname = (String) request.getParameter("Name");
         String jemail = (String) request.getParameter("Email");
         String jcomments = (String) request.getParameter("Comments");
    try
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(ClassNotFoundException e)
         out.println("class error");
    try
         Connection databaseConnection = DriverManager.getConnection("jdbc:odbc:terrycontacts");
         Statement stmt = databaseConnection.createStatement();
         String sqlInsertString ="INSERT INTO contacts(name,email,comments) VALUES('"+jname+"','"+jemail+"','"+jcomments+"')";
         stmt.executeQuery(sqlInsertString);
         databaseConnection.commit();
         databaseConnection.close();
    catch(SQLException e)
         out.println("sql error");
         out.close();
    }

  • 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

Maybe you are looking for

  • Text in document has disappeared

    Strange things are happening here.  My wife created and saved her resume' and the test has disappeard.  The document still shows in the finder with 29 kb of data showing in info.  This happened once before on the same document, but then the text myst

  • Bridge CS6 can't open image with Photoshop CS6

    I installed Bridge CS6 and Photoshop CS6 with my Mac Pro with drive 1, which was cloned with drive 2 as a backup. Now every time I try to open my RAW file in Bridge, it opens the file with the Photoshop with drive 2 instead of 1. I have tried to ejec

  • Copy and paste buffers not working correctly in iOS 8.1m

    Both iPads2's in my family arsenal are exhibiting what I believe to be a bug in the iOS8.1 (perhaps corrected by 8.1.1?), in the cut/copy & paste buffer stack. When invoking the operation to copy and paste data from one application to another, the pa

  • FocusManager childhandler()  problem with flex4

    Hi, The below error is my problem,,,,,,I am using Flex4 SDK TypeError: Error #1009: Cannot access a property or method of a null object reference.     at mx.managers::FocusManager/childHideHandler()[E:\dev\4.0.0\frameworks\projects\framework\s rc\mx\

  • Inputting the right refresh rates

    I found the specficiations for my laptop, but I don't really know how to transfer these numbers to what Xorg require the info Dell gives me Horizontal: ±65° (WSXGA+) Vertical: ±50° (WSXGA+) my specs at http://support.dell.com/support/edocs/s - #wp105