SQL Anywhere pass row as parameter to stored procedure

394 Views Asked by At

we're using an ERP-System based on SQL Anywhere 16. My new task is to log some changes to specific rows of a specific table. I planned to create a trigger that compares the values of the old row to the values of the new row. If old and new value don't match it should write an entry to another table. To add or edit the Trigger i will have to log out all users... unfortunately... So my question is: Can i pass the two rows to a stored procedure to do my work there, because i can edit it while the users are working? Any ideas? Thanks for your help!

1

There are 1 best solutions below

2
On

Here is the vb.net code for how to make xml

Dim dt As DataTable
--Fill dt data
Dim result As String
    Using sw As StringWriter = New StringWriter
        dt.WriteXml(sw)
        result = sw.ToString().Replace("�", "") 'Replace Char(0) with empty string
    End Using

Here is the stored procedure to parse the @xml

DECLARE @doc int
EXEC sp_xml_preparedocument @doc OUTPUT, @xml

SELECT column1, column2, DateAdd(hour, yourtimezone,date) AS column3 --UCT to local
FROM OPENXML(@doc,'/NewDataSet/TableName',2)
WITH (column1 int, column2 varchar(50),column3 smalldatetime)