I want to log data changes in some of Oracle tables. Structure of log table is:
(...)
olddata (xmltype)
newdata (xmltype)
Data changes will be logged by triggers on update, insert, delete Is there any easy way to make code below working?
log.olddata := magic_rowtype_to_xml_function(old);
I have seen DBMS_XMLGEN.getXmltype('select * from table where row_id = x')
but I haven't found how to force it to work with rowtypes.
EDIT
I have found little work-arround:
First get a little information about table:
select 'xmlelement("'|| column_name||'",new.' || column_name || '),' from all_tab_columns where lower(table_name) = 'my_table';
and just copy paste result into
select xmlelement("doc",
--paste here
) from dual;
Ugly, but working.