Example: XML Export For Update

Previous Next

See Also

Here is an example of a constraint that calls the XML export method, and updates a database column with the result of the INVOKE statement.

Whenever a person is updated, the fact that this PERSON record is updated is stored in XML format in the XMLupdate column of the PERSON_XML_LOG table.

UPDATE     PERSON_XML_LOG pxl

SET     pxl.XMLupdate =

       (

        INVOKE XML.export

        WITH

        SELECT 'Update' ExecutionType, *, OLD(*)

        FROM     PERSON p

        WHERE    p.id = pxl.person_id

)

After an update of "John Smith" to "Johnny Smith", the XMLupdate column of the PERSON_XML_LOG table contains:

<Persons documentName="Persons">

   <PERSON ID="112" FAMILY_NAME="Smith" FIRST_NAME="John">

       <Update ID="112" FAMILY_NAME="Smith" FIRST_NAME="Johnny"/>

   </PERSON>

</Persons>

NOTES:

· The 'Update' execution type is only useful in constraints in combination with old values.

 

· The execution type is the same for all exported row elements.