"VirtTransactionLogsRead" . . . . . . . "a8b72f39b5f50e3e14fa7a14f89fbf7e" . "2017-06-13T05:45:53Z" . "%META:TOPICPARENT{name=\"VirtTipsAndTricksGuide\"}%\n\n---++Reading Virtuoso Transaction Logs\n\n---++What?\nA Stored Procedure that uses the in-built [[http://docs.openlinksw.com/virtuoso/fn_read_log.html][read_log()]] function to read the Transaction log of a Virtuoso Instance, in regards to Quad Store activity.\n\n---++Why?\nThere are times when you application functionality benefits from being able to read Virtuoso Transaction logs. In particular, the database triggers on the RDF_QUAD table are not meant to be supported in Virtuoso 7+, thus reading transaction logs as indicated below is the recommended method for tracking changes to the RDF_QUAD table.\n\n---++How?\n\nTo read the changes made to the RDF_QUAD table i.e RDF data, one can use the following Virtuoso Stored procedure that uses the in-built [[http://docs.openlinksw.com/virtuoso/fn_read_log.html][read_log()]]:\n\n---+++Sample Scenario\n\n 1 Insert sample data so to change the rdf_quad index:\n\nSQL> SPARQL INSERT INTO {

};\n\n 1 Create the following example procedure:\n\ncreate procedure rlt (in f any, in inpos int := 0) \n{ \n declare h, op, g, s, p, o any;\n declare pos int;\n result_names (op, g, s, p, o);\n h := file_open (f, inpos);\n declare r, rr any;\n while ((rr := read_log (h, pos)) is not null)\n {\n declare rw, k any;\n declare i int;\n rw := null;\n k := null;\n for (i := 1; i < length (rr); i := i + 1)\n {\n\t r := rr[i];\n\t if (r[0] = 13) -- key insert\n\t {\n\t rw := r[2];\n\t op := 'I';\n\t }\n\t else if (r[0] in (1,8,9)) -- insert,soft,replacing\n\t {\n\t rw := r[1];\n\t op := 'I';\n\t }\n\t else if (r[0] in (3,14)) -- delete\n\t {\n\t rw := r[1];\n\t op := 'D';\n\t }\n\t if (rw is not null)\n\t {\n\t k := rw[0];\n\t if (k = 273) -- RDF_QUAD, should check with SYS_KEYS\n\t\t{\n\t\t result (op, __ro2sq (rw[1]), __ro2sq (rw[2]), __ro2sq (rw[3]), __ro2sq (rw[4]));\n\t\t}\n\t }\n\t}\n } \n result (pos + inpos, '', '', '', '');\n}\n;\n\n 1 Call the procedure:\n * In case of no changes to the RDF_QUAD Index are done, it will return:\n\nSQL> rlt('tmp/Virtuoso.trx');\nQuery result:\nop g s p o\nANY ANY ANY ANY ANY\n8403\nNo. of rows in result: 1\n\n * In case of changes to the RDF_QUAD Index are done ( example with the short INSERT we did above), it will return for example:\n\nSQL> rlt('tmp/Virtuoso.trx');\nQuery result:\nop g s p o\nANY ANY ANY ANY ANY\nI g s p o\n71446\nNo. of rows in result: 2\n\n\n\nTo read the transaction log in general, one should use the Virtuoso [[http://docs.openlinksw.com/virtuoso/fn_read_log.html][read_log()]] function.\n\n---++Related\n\n * [[http://docs.openlinksw.com/virtuoso/vsp1.html#longhttptrans][Long HTTP Transactions.]]\n * [[http://docs.openlinksw.com/virtuoso/clusteroperation.html#clusteroperationtransc][Cluster Operations transactions.]]\n * [[http://docs.openlinksw.com/virtuoso/fn_log_text.html][Insert a SQL statement into the roll forward log.]]\n * [[http://docs.openlinksw.com/virtuoso/fn_log_enable.html][Enable logs.]]" . . . . . "VirtTransactionLogsRead" . "2017-06-13T05:45:53.673864"^^ . . "2017-06-13T05:45:53.673864"^^ . . . . . "2017-06-13T05:45:53Z" . "VirtTransactionLogsRead" . . . .