Multi Row Madness: Insert?

Hey Guys,
I've been hitting my head against a cobbled wall trying to figure this one out.
I'm creating a form that needs to support versioning - so instead of ever using an update the form always inserts a copy of the data into the database with an incremented version number.
Frustratingly enough the form requires a dynamic amount of parts - best editting and represented but a tabular form. But MRU and MRD.... where is Multi-Row Insert?
I've tried everything i can to load the information and then change the version - but doing this will result in a ORA-20001: Error in MRU as the data in database is different and cannot "update" the row for old records (when i just want it to copy with a new version number).
The tables work with a header table that had id and version attributes making a combined pk, and the parts table with id and version which references the header table, and a parts_id to uniquely identify itself.
Is there any suggestions on this issue? I was thinking about adding an extra value and adding a trigger to do the inserting instead - but i fear this approach may change the information in the current version (i'm not that familiar with oracle databases... so prefer to try to find a solution in apex).
I'm using 2.2.
cheers,
Alex

But MRU and MRD.... where is Multi-Row Insert?
The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
I was thinking about adding an extra value and adding a trigger to do the inserting instead
Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
Something like
create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
create or replace trigger mytrig
after insert or update or delete on mytable
for each row
declare
l_action varchar2(1);
begin
  if inserting then l_action := 'I';
  elsif updating then l_action := 'U';
  elsif deleting then l_action := 'D';
  end if;
  insert into mytable_hist
  values
  l_action,
  version_no_seq.nextval,
  nvl(:new.col1,:old.col1), 
  nvl(:new.col2,:old.col2), 
  nvl(:new.col3,:old.col3), 
end;
/

Similar Messages

  • Fill multi row before insert

    hello guys I want to fill a block with multiple rows before inserting the rows data are from 2 blocks in the form I tried to use next_record , down but they are all restricted here an example of what I want to do
    I have block1 , block2 and block3 and I want to fill block3 with the first row of each block before inserting the data in the block3
    what should I do?
    Thanks in advance guys

    But MRU and MRD.... where is Multi-Row Insert?
    The MRU process does an update for existing rows and insert for new rows (that were added using the Add Row button)
    I was thinking about adding an extra value and adding a trigger to do the inserting instead
    Yes, a row-level trigger on the underlying table would be the best way to approach this problem. Let the APEX MRU and MRD processes do their job and your row-level trigger can keep inserting rows into a separate audit/history table with structure identical to the main table (plus sequence generated version number).
    Something like
    create table mytable_hist as select 'U' dml_action, 1 version_no,a.* from mytable a where 1=2;
    create or replace trigger mytrig
    after insert or update or delete on mytable
    for each row
    declare
    l_action varchar2(1);
    begin
      if inserting then l_action := 'I';
      elsif updating then l_action := 'U';
      elsif deleting then l_action := 'D';
      end if;
      insert into mytable_hist
      values
      l_action,
      version_no_seq.nextval,
      nvl(:new.col1,:old.col1), 
      nvl(:new.col2,:old.col2), 
      nvl(:new.col3,:old.col3), 
    end;
    /

  • Conditional multi row Table insert

    Hello,
    I've a multi insert table, with 1 new row (_1B). In some cases I don't want a
    new row, because there are enough rows created, how should I prevent the new row on the iterator?
    Anyone an idea?
    Regards,
    Ruben Spekle

    Wouldn't it be easyer to just omit the _1B if your condition occurs?
    model = "${ ui:conc ( 'yourtablename' , ui:cond ( yourcondition , '_1B' , '' ) ) }"
    Anton

  • Multi-row insert in master-detail tables

    Hi, I'm using jdev 10.1.3.2 with jheadstart and my problem is:
    I hava a master-detail structure, both are tables and my goal is that I want multi insert (exactly 3) in master and detail table when user makes new order(some business scenario). I cannot create rows in master or detail VO by overriding create() method because its entities have complex primary keys and some part of this key is populated by the user with lov. So I set in jhs new rows to 3 and checked multi-row insert allowed but the problem is that overall I can only create rows in master table after I submit form. I want to create row in master table and fill rows in detail table, and after that I want to have opportunity to create second (or even third) row in master table and fill rows in detail table.
    thanks for help.
    Piotr

    See JHS DevGuide: 3.2.1. Review Database Design:
    If you are in the position to create or modify the database design, make sure all
    tables have a non-updateable primary key, preferably consisting of only one
    column. If you have updateable and/or composite primary keys, introduce a
    surrogate primary key by adding an ID column that is automatically populated.
    See section 3.2.4 Generating Primary Key Values for more info. Although ADF
    Business Components can handle composite and updateable primary keys, this
    will cause problems in ADF Faces pages. For example, an ADF Faces table
    manages its rows using the key of the underlying row. If this key changes,
    unexpected behavior can occur in your ADF Faces page. In addition, if you want
    to provide a drop down list on a lookup tables to populate a foreign key, the
    foreign key can only consists of one column, which in turn means the referenced
    table must have a single primary key column.
    Groeten,
    HJH

  • Issues in Table with Multi-Row Insert

    I have created a master detail screens using jheadstart on 2 separate pages, Master in the Form layout and detail in the Table Layout with multi-row insert, update and delete flags ON. Have set the New Rows count = 2.
    Issue 1
    If I try to delete any existing rows, it gives error for new rows saying value is required for the mandatory fields. It should just ignore the new rows if I have not updated any values for any attributes in the those row(As it does for non Master-Detail Table layout). I guess this might be happening because the jheadstart code is setting the foreign key for new rows the detail, but not resetting the status of the rows back to INITIALIZED.
    I also noticed that the create() of underlying EO is getting called for those blank rows when I click on 'Save' button, even if I have not changed any data in those rows.
    Issue 2
    When I try to select the new rows also for deletion, I am getting a '500 Internal Server Error' with following stack trace... This is also happening for normal (non Master-Detail) Table layout.
    java.lang.IllegalStateException: AdfFacesContext was already released or had never been attached.     at oracle.adf.view.faces.context.AdfFacesContext.release(AdfFacesContext.java:342)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:253)     at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
    Issue 3
    I have put some validation code in the validate() method in the MyEntityImpl.java class.
    The validate method seems tobe getting called lots of times, in my case 20 times, where the new rows are just 2.
    Environment:
    Jdeveloper 10.1.3, JHeadStart 10.1.3 build 78, Windows XP
    thanks

    Thanks for the reply.
    Issue 1:
    What I have observed that in case of multi-row select enabled tables, the blank rows do not have any data. This is because the EO's create() method is called only when we post the data using 'Save' button. Thus the Foreign Keys are also not setup. This is a correct behavior since create() and FK setups etc should get done only if the user has inputted any value in the new rows and thus intend to insert new data into the table.
    I am able to find the exact cause of this issue. It is happening because in the details table, I have a column which needs tobe shown as checkbox. Since we can only bind checkbox to an Boolean attribute in VO, I have created a transient attribute of type Boolean, which basically calls the getter/setter of actual attribute doing the String "Y"/"N" to true/false conversion. Here is code for the transient attribute getter/setter
    public Boolean getDisplayOnWebBoolean() {
    return "Y".equals(getDisplayOnWeb()) ? Boolean.TRUE : Boolean.FALSE;
    public void setDisplayOnWebBoolean(Boolean value) {
    if(Boolean.TRUE.equals(value))
    setDisplayOnWeb("Y");
    else
    setDisplayOnWeb("N");
    Now when I click on the "Save" button, the setter for the boolean field is getting called with the value = false and this is resulting into the row being maked as dirty and thus the validation for the required attributes is getting executed and failing.
    Issue 2:
    Confirmed that correct filter-mapping entries are present in the web.xml.
    Now when I select the new blank rows for deletion and click save, following exception is thrown:
    java.lang.ClassCastException: oracle.jheadstart.controller.jsf.bean.NewTableRowBean at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.getRowsToRemove(JhsCollectionModel.java:412) at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.doModelUpdate(JhsCollectionModel.java:604) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.processModelUpdaters(JhsPageLifecycle.java:541) at oracle.jheadstart.controller.jsf.lifecycle.JhsPageLifecycle.validateModelUpdates(JhsPageLifecycle.java:571)
    thanks - rutwik

  • Master-Detail Multi-Row Insert

    Im still using Oracle forms 6i. How do we create here in ADF for the transaction in master-detail operation specially in inserting multi-row in detail. In forms we can use key-next item trigger next_record for new record transaction for drugs or we can use bar code scanning to insert new records & automatically go to next records waiting for another input...
    pls help me i want to upgrade & pls sorry for my english...
    just want this adf behave like forms in terms of master-detail transaction entry...
    i appreciate if someone can help me or give me demo file to download & play with it...
    Edited by: user8983555 on Nov 10, 2010 10:30 AM

    tnx for the fast reply..
    im new with jdeveloper and no knowledge in java or html. im concentrated in pl/sql , forms 6i.We still using this until now in character base in unix environment but some module in gui mode.im working in hospital which is complete informations sytem (stock,pharm..etc...gl...) which in bulk transactions specially patients outclinic & inpatients charges.now we have also this reservations system for out clinics thats the reason im like to develop for in a web that a patient can reserve on line and i dont like running our application in different front end (forms 6i &jdeveloper).
    (now currently checking form10g & just set up AS10g which is working.can deploy and connect,LAN). but im very interested in ADF when i see the demo on Oracle website.
    now our company pplanning to change our application to power builder whiich is not good in performance regarding in hadling big databases (slow query,needs burst AS...) thru to the demonstration of the
    apllication vendors.
    im very glad if you can help. can you post a links or demo file to do this as you said....(You can replicate the code in the button in some other event on your page, for example when the value of the last field in the row is changed.
    It all comes down to the question of when you actually want to create a new row, and in that event you call the createInsert method.)
    this is my only problem now to make this master-detail multi-row insert like ora form.
    again sorry for my english...

  • Sqlite multi-row insert

    In php & mysql I am used to being able to do multi row inserts into a table using;
    INSERT INTO table (column1,column2) VALUES (val1,val2),(val3,val4)
    Is there any Sqlite equivalent? I need to populate around 100 rows on first run of a mobile application.
    Thanks,
    Pete

    If what _spoboyle recommends doesn't work in AIR and if you haven't already, look into the SQLConnection.begin() and commit().  It seems at least you can group your SQL transactions.

  • ADF Editable Table : CANNOT Insert Multi Rows , Please hellppppssss

    Hi All,
    Our customer requirement is being able to insert Multi Rows in an Editable Table and submit ALL of them with just one Click ?
    Is it Really Possible ?
    I have tried, even I can insert three Empty Rows and Fill them all with values, when I press Submit ONLY one row will be submitted, the other TWO will become BLANK again, is this my code is wrong ?
    Or this is limitation of ADF Editable Table ?
    Here is my codes, I have tried two ways, all same problem :
    (1) public String create_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Create");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    public String myCreate_action() {
    create_action();
    create_action();
    create_action();
    return null;
    (2) public String createMultiRows() {
    DCBindingContainer dcbc = (DCBindingContainer)getBindings();
    //get iterator binding
    DCIteratorBinding ib = (DCIteratorBinding)dcbc.get("DeptView1Iterator");
    // get viewobject
    ViewObject vo = ib.getViewObject();
    System.out.println(vo.getCurrentRowIndex());
    vo.clearCache();
    int currentRowIndex = vo.getRowCount() -1;
    Row row1 = vo.createRow();
    row1.setNewRowState(Row.STATUS_NEW);
    vo.insertRowAtRangeIndex(++currentRowIndex, row1);
    Row row2 = vo.createRow();
    row2.setNewRowState(Row.STATUS_NEW);
    vo.insertRow(row2);
    Row row3 = vo.createRow();
    row3.setNewRowState(Row.STATUS_NEW);
    vo.insertRow(row3);
    return null;
    Please help... I am stuck ...
    Thank you very much,
    xtanto

    Xtanto,
    Could you try changing
    bindings.getOperationBinding("Create");to
    bindings.getOperationBinding("CreateInsert");in your first example to see if it fixes your problem?
    Regards,
    John

  • Multi Row Insert

    I have read a few posts that mention a multi-row-insert but I can't find it.
    There is a multi row update and a multi row delete.
    I am using html db 1.6. We will be upgrading after we get this version of our app up and running, but don't want to take time out for the upgrade right now.
    Is multi_row_insert new to Application Express 2.0?
    Thanks,
    Gregory

    No, the multi row insert is not new to 2.0
    The builtin MRU processes handle multi-row updates and multi-row inserts. However, the default Add Rows process that the wizard creates on a tabular form does create only 1 blank row when you click the Add Row button. To increase this, just open the Add Rows process page and change 1 to a different number.

  • Multi-row uipdate with an insert into another table [I think]

    Folks,
    I'm trying to get a multi row region with a checkbox against each row. When a user checks a box I want to insert a corresponding row into another table. So I've tried to simplify the questions and distill the problem down using the EMP table.
    So, here goes:
    I have table EMPS, which looks like this:
    EMPNO     Number     
    FIRSTNAME     Varchar2(9)     
    LASTNAME     Varchar2(10)     
    HIREDATE     Date
    I have table EMP_CANDIDATES, which looks like this:
    EMPNO     Number     
    SELECTION_DATE     Date     
    NOTES Varchar2(53)
    - I want to create a multi-row region based on EMPS, with a checkbox on each employee row.
    - The user should be able to select any number of employees in the region and then press submit.
    - on-submit there needs to be a process, which inserts a record into EMP_CANDIDATES for each checked employee.
    I've tried pre-populating a collection with the EMPS records and using apex_item.checkbox to produce a checkbox, using this code:
    =============
    if apex_collection.collection_exists(p_collection_name=>'EMPS') then
    apex_collection.delete_collection(p_collection_name=>'EMPS');
    end if;
    apex_collection.create_collection_from_query(
    p_collection_name=>'EMPS',
    p_query=>'select
    p.empno,
    p.hiredate,
    p.firstname,
    p.lastname,
    null selection
    from emps p');
    =========
    I can create a report region on this using tthe following SQL:
    select c001 empno
    , c002 hiredate
    , c003 firstname
    , c004 lastname
    ,apex_item.checkbox(1,c005) selection
    from apex_collections
    where collection_name ='EMPS'
    ======
    So how do I now get a MRU that will insert a row into EMP_CANDIDATES for each checked row in my region? Or have I gone about this the wrong way?
    TFH
    Derek

    Hi Derek,
    Firstly, your checkbox should be on the c001 field as this is the one that contains your empno.
    Then, you need a page process that can be triggered by a button. The process should be set to run "On submit (After computations and validations)" and the PL/SQL code would be something like:
    DECLARE
    v_empno NUMBER;
    BEGIN
    IF HTMLDB_APPLICATION.G_F01.COUNT = 0 THEN
    raise_application_error(-20001, 'Please select at least one employee!');
    END IF;
    FOR i IN 1.. HTMLDB_APPLICATION.G_F01.COUNT LOOP
    v_empno := TO_NUMBER(HTMLDB_APPLICATION.G_F01(i));
    INSERT INTO EMP_CANDIDATES VALUES (v_empno, whateverdate, whatevernotes);
    END LOOP;
    END;
    This will firstly count the items that have been ticked - if there aren't any, the user gets an error message. If there is at least one item ticked, the code will loop through these, get the empno relating to the ticked box and insert a record into the emp_candidates table. Please note that no account is taken here of any validation on this second table - if you need to ensure, for example, uniqueness of records in this table, you will have to update the above to perform this validation.
    Regards
    Andy

  • Multi row insert with checkboxes and textfield

    i'm trying to build a multi row insert on tabular form.
    i have checkboxed to choose the rows which i want to insert.
    in this row i have to insert a value into the textfield.
    but when i'm looping my checkec checkoxes my prcedure always takes the first textfields in my report.
    what's going wrong?
    select apex_item.checkbox(30,ar_id, 'class="checkThis"') as ar_id
    ,apex_item.display_and_save(31,ar_nr) as ar_nr
    ,ar_name
    ,apex_item.text(32,null) as Menge
    from ar
    FOR i IN 1.. APEX_APPLICATION.G_F30.COUNT LOOP
    insert blabla (st_profil_id, ar_id,menge)
    values(:P5_st_profil_id,APEX_APPLICATION.G_F30(i),APEX_APPLICATION.G_F32(i));
    end loop;

    Hi,
    Please read the following
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_app.htm#CHDGJBAB
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_item.htm#CHDDCHAF , especially the Creating an On-Submit Process.
    Cheers,

  • Multi Row Inserts

    Is there any way of providing Multi Row Inserts in a single region.
    I am looking for a way to add several records at once in a table format, much like the multi row update functionalty.
    Is this possible?

    Can you use an OUTPUT clause? See examples
    MERGE INTO dbo.Customers AS TGT
    USING dbo.CustomersStage AS SRC
      ON TGT.custid = SRC.custid
    WHEN MATCHED THEN
      UPDATE SET
        TGT.companyname = SRC.companyname,
        TGT.phone = SRC.phone,
        TGT.address = SRC.address
    WHEN NOT MATCHED THEN 
      INSERT (custid, companyname, phone, address)
      VALUES (SRC.custid, SRC.companyname, SRC.phone, SRC.address)
    WHEN NOT MATCHED BY SOURCE THEN
      DELETE
    OUTPUT 
      $action AS the_action, deleted.custid AS del_custid, inserted.custid AS ins_custid;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Inserting new rows in a JSP multi-row page

    Hi all.
    I´ve been implementing a JSP multi-row editable page according to the paper:
    http://www.oracle.com/technology/products/jdev/tips/mills/JSP_Multi_Row_Edits.html
    I noted that the code provided in the example just considers handling updates from the multi-row page, by comparing the existing rows in the ControlBinding rangeSet with the ones that came from the page.
    However, I need the ability to handle new rows from the same multi-row form that came from the page. So how can I achieve this task? What code should I include in the processUpdateModel method to handle new inputs?
    regards.
    Denis

    I think I will have to look inside the JHeadStart source code that extends DataAction, understand how that code works, and finally get the pieces I'm interested in...

  • Tabular form - Multi row delete error

    Apex 4.0.2
    We have a simple CRUD type of application on a bunch of tables built using Apex v1.6 that has, over the years, been upgraded to v4.0.2 and it is working mostly fine. It uses all out-of-the-box standard components, forms, classic reports, nothing too fancy. Recently one of the tabular forms started to misbehave, the multi-row-delete process raises a No Data Found error. The tabular form is based on a view with a INSTEAD OF trigger to handle the DML. Manually deleting the row in SQL*Plus works fine delete from mytab here pk_id = :pk_id but selecting the same row in Apex and clicking Delete raises the error.
    How does one go about troubleshooting & fixing this sort of thing? I tried re-saving the region in the Builder, exporting/importing the entire app, nothing. Running in Debug mode doesn't really provide any additional information, just that the MRD process failed. Tabular forms are the most frustrating, opaque component in Apex, wish they were easier to troubleshoot.
    Any ideas?

    Hello Vikas,
    >> How does one go about troubleshooting & fixing this sort of thing?
    By given us a bit more information :)
    • Is it a manual Tabular Form (using the ITEM API) or a wizard created one?
    • Are the Insert/Update operations work correctly? If not, what is the type of your PK column(s)?
    • If the problem is limited to the Delete operation, maybe the problem lies with the checkbox column. Are you sure that on page it is rendered as the f01 column?
    • As triggers are involved, can you save the PK that the trigger sees? Is it the expected value?
    • Are there any other processes that are fired before the DML process? If so, maybe the problem is with them. You can temporarily disable them and see if it change anything.
    >> Tabular forms are the most frustrating, opaque component in Apex, wish they were easier to troubleshoot
    Yes, I agree. However, I believe that 4.1 made some serious advancement where Tabular Form is concerned. Having simplified Tabular Form related Validations and Process should make things easier, and as a result, prone to less errors. Still, the main problem is that the type of error you are talking about is usually the result of metadata problems and these are indeed very hard to track.
    Regards,
    Arie.
    ♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    ♦ Author of Oracle Application Express 3.2 – The Essentials and More

  • SQL 2008 Trigger to handle multi rows scenario

    I have created below trigger to start logging the company changes from the table1 into another audit table. It works fine with single row but crashing with identical change with multiple rows. Can you please help me to update the trigger to handle multi-row
    scenario. Thanks.
    GO
    IF
    NOT EXISTS
    (SELECT
    * FROM sys.objects
    WHERE object_id
    = OBJECT_ID(N'[dbo].[Company_AuditPeriod]')
    AND type
    in (N'U'))
    CREATE
    TABLE [dbo].[Company_AuditPeriod](
          [Client] [varchar](25)
    NOT NULL,
          [Period] [varchar](25),
          [Table_Name] [varchar](25),
          [Field_Name] [varchar](25),
          [Old_Value] [varchar](25),
          [New_Value] [varchar](25),
          [User_ID] [varchar](25)
          [Last_Update] [datetime],
            [agrtid] [bigint]
    IDENTITY(1,1)
    NOT NULL,
    ON [PRIMARY]
    GO
    --create trigger
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    TRIGGER [dbo].[Table1_Update]
    ON [dbo].[Table1]
    FOR
    UPDATE
    NOT
    FOR REPLICATION
    AS
    BEGIN
    DECLARE
          @status          
    varchar(3),
          @user_id   
    varchar(25),
          @period          
    varchar(25),
          @client          
    varchar(25),
          @last_update
    datetime
    DECLARE
          @Old_status      
    varchar(3),
          @Old_user_id     
    varchar(25),
          @Old_period      
    varchar(25),
          @Old_client      
    varchar(25)
    SELECT
          @status    
    = status,
          @user_id   
    = user_id,
          @period          
    = period,
          @client          
    = client,
          @last_update
    = last_update
    FROM Inserted
    SELECT
          @Old_status
    = status,
          @Old_user_id     
    = user_id,
          @Old_period      
    = period,
          @Old_client      
    = client
    FROM Deleted
    If @Old_status <> @status
    INSERT INTO Company_AuditPeriod
    VALUES ( @client, @period,
    'Table1',
    'period',@old_status, @status, @user_id, @last_update)
    END
    GO

    Sorry for the confusion.
    I just made sure the table name is same in sys.objects statement and create table statement (there was a typo)
    IF
    NOT EXISTS
    (SELECT
    * FROM sys.objects
    WHERE object_id
    = OBJECT_ID(N'[dbo].[Company_AuditPeriod]')
    AND type
    in (N'U'))
    CREATE
    TABLE [dbo].[ Company_AuditPeriod](
    Earlier you created Trigger on Company_AuditPeriod but
    We have to create trigger on Table1 please with multi row scenario. Thanks.
    --Company_AuditPeriod DDL
    GO
    IF
    NOT EXISTS
    (SELECT
    * FROM sys.objects
    WHERE object_id
    = OBJECT_ID(N'[dbo].[Company_AuditPeriod]')
    AND type
    in (N'U'))
    CREATE
    TABLE [dbo].[ Company_AuditPeriod](
          [Client] [varchar](25)
    NOT NULL,
          [Period] [varchar](25),
          [Table_Name] [varchar](25),
          [Field_Name] [varchar](25),
          [Old_Value] [varchar](25),
          [New_Value] [varchar](25),
          [User_ID] [varchar](25)
          [Last_Update] [datetime],
            [agrtid] [bigint]
    IDENTITY(1,1)
    NOT NULL,
    ON [PRIMARY]
    GO
    --Table1  DDL
    CREATE TABLE [dbo].[Table1](
    [bflag] [int] NOT NULL,
    [client] [varchar](25) NOT NULL,
    [copies] [int] NOT NULL,
    [cost_bio] [decimal](28, 8) NOT NULL,
    [cost_cpu] [decimal](28, 8) NOT NULL,
    [cost_dio] [decimal](28, 8) NOT NULL,
    [date_ended] [datetime] NOT NULL,
    [date_started] [datetime] NOT NULL,
    [description] [varchar](255) NOT NULL,
    [expire_days] [int] NOT NULL,
    [func_arg] [varchar](255) NOT NULL,
    [func_id] [int] NOT NULL,
    [ing_status] [int] NOT NULL,
    [invoke_time] [datetime] NOT NULL,
    [last_update] [datetime] NOT NULL,
    [mail_flag] [tinyint] NOT NULL,
    [me_mail_flag] [tinyint] NOT NULL,
    [module] [char](3) NOT NULL,
    [order_date] [datetime] NOT NULL,
    [orderno] [int] NOT NULL,
    [output_id] [int] NOT NULL,
    [poll_status] [char](1) NOT NULL,
    [printer] [char](16) NOT NULL,
    [priority] [char](1) NOT NULL,
    [priority_no] [int] NOT NULL,
    [process_id] [int] NOT NULL,
    [report_cols] [int] NOT NULL,
    [report_id] [varchar](255) NOT NULL,
    [report_name] [varchar](25) NOT NULL,
    [report_type] [char](1) NOT NULL,
    [server_queue] [char](12) NOT NULL,
    [status] [char](1) NOT NULL,
    [step_id] [char](8) NOT NULL,
    [system_name] [char](8) NOT NULL,
    [used_bio] [int] NOT NULL,
    [used_cpu] [int] NOT NULL,
    [used_dio] [int] NOT NULL,
    [user_id] [varchar](25) NOT NULL,
    [variant] [int] NOT NULL,
    [agrtid] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
     CONSTRAINT [PK_acrrepord001] PRIMARY KEY NONCLUSTERED 
    [agrtid] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [INDEX]
    ) ON [PRIMARY]
    G0<o:p></o:p>
    --create trigger
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    TRIGGER [dbo].[Table1_Update]
    ON [dbo].[Table1]
    FOR
    UPDATE
    NOT
    FOR REPLICATION
    AS
    BEGIN
    DECLARE
          @status          
    varchar(3),
          @user_id   
    varchar(25),
          @period          
    varchar(25),
          @client          
    varchar(25),
          @last_update
    datetime
    DECLARE
          @Old_status      
    varchar(3),
          @Old_user_id     
    varchar(25),
          @Old_period      
    varchar(25),
          @Old_client      
    varchar(25)
    SELECT
          @status    
    = status,
          @user_id   
    = user_id,
          @period          
    = period,
          @client          
    = client,
          @last_update
    = last_update
    FROM Inserted
    SELECT
          @Old_status
    = status,
          @Old_user_id     
    = user_id,
          @Old_period      
    = period,
          @Old_client      
    = client
    FROM Deleted
    If @Old_status <> @status
    INSERT INTO Company_AuditPeriod
    VALUES ( @client, @period,
    'Table1',
    'period',@old_status, @status, @user_id, @last_update)
    END
    go

Maybe you are looking for

  • CNXSRV.dll missing in BO 4.0 designer.exe does not start

    Hi, I installed BO 4.0 in windows server 2008 and everything including information design tool, webi, cmc is working but the Universe design tool(designer.exe). from some of the previous post i thought it was an issue with its drivers being 64 bit wh

  • How to use HRRCF00_PRE_DATAOVERVIEW

    Hello I am trying to add some additional data in the candidate's data over view: There is a badi available for this: it doesnt have an extended documentation. It says i can export some data to a function group or an external area and call it back in

  • Sim lock

    Hi is there anyone out there that can help this idiot. Yesterday I changed my pin number for my sim and forgot to write it down. I have forgotten this bloody number and wonder if there is anyway of unlocking my phone without locking it completely. Pl

  • Lumia 620 and Class 10 SDcard.

    Hi guys, I am new to this forum. I am planning to buy a SDcard for my lumia 620. I am getting vague reviews about class 10 support with 620. Its working for some and not working for few. Kindly help me out. I know class 6 is prefered for my kind of d

  • Adobe Premiere Pro CC 2014.2 Unusuable - Crash

    Hi, just updated to Premier Pro CC 2014.2, and it's unusuable. Drivers all updated, Windows 7 Pro. Intel Core i7 8GB Ram 64 bit Application crashes within usually 1-2 minutes of launch at random moments: Import transparent PNG 900px wide - instant cr