Objet storing in the database

Author: se8mis@ceb.lk (se8mis)

How I clone the current object and save the new cloned object by changing some values and also need to save old object by changing the status

Eg Assume I have a Object   Document  -> Name, Id ,status,revision     I need to create another document obj with same values and need to save new one as latest revision and old one as old revision


  1. Hi,

    one option is not to show the database entity at all,
    but let the user work on a non-database copy.
    Not quite sure if one can use a functional subtype with read and write trigger disabled.

    I personally prefer using uniface lists with the /occ switch to transfer data from and to the different entities.
    Be sure to have set the entity fieldlist to "All fields" to get all the data.

    After the modifications are done and the user wants to SAVE his results,
    just compare the contents of the working entity with the one from the database.

    In the background where you have your real database entity;
    just run a creocc for the new information (including a new primary key)
    flag your old version as you need to and then run a store inclusing commit.

    *** another option would be using a "release command" to offer the user a new occurence.
    In case the new information is written to the database (with a new primary key),
    you have to re-read the original dataset, modify there, store it to the database and then commit both transactions.


    SUccess, Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. When does it count as a new occurrence? Only on modify of document?

    What is the data type of the document? How is it modified? e.g. OLE object....

    Author: Iain Sharp (i.sharp@pcisystems.co.uk)
  3. new occurance will create after edit the document line count .... assume we hav a feild in the document obj , Number_Of_lines, user will see the document detail in a editable table,once he edit the No_of_lines count (Double val) and click Update... system should store new object and older one should also update its status to edited or somtihin ...

    Author: se8mis (se8mis@ceb.lk)
  4. If you are sing a relational database supporting database triggers, why not define  DATABASE TRIGGER ON UPDATE in the database:

    In this database trigger: BEFORE UPDATE: insert into new record en copy OLD information to new record, with STATUS field modified;

    So, when you modify datafields from the entity in UNIFACE followed by STORE, the database will fire the ON UPDATE database trigger before the modification is fixed in the database.

    The database will insert the CLONE object which is a copy of original record with the modified status and directly after hat updates the currect record with the modifications passed by Uniface.

    So, you your code will be simplified in Uniface without having to care for the clone. Just update the existing occurence and you get clone for free.

    Even so if the record is updated outside of Uniface the ON UPDATE TRGGER  will be fired.


    Edu Kornmann.




    Author: Edu Kornmann (edu@kornmann.com)