NXLog postgresql ID manipulation?
Is it possible to manipulate the ID in SQL queries done by NXLog agent? The documentation states this in im_dbi module:
The module automatically appends a WHERE id > ? LIMIT 10 clause to the statement. The result set returned by the SELECT statement must contain an id column which is then stored and used for the next query.
I have a database that does not get new reqords very often so i want to reset that id for testing and development purposes in the receiving end.
It sounds like your id
field isn't always higher than the previous id
then?
Have you tried something like SELECT RecordID*100 AS id, * FROM dbo.test1 WHERE RecordID > ?
. to add some bulk to it? You will still need to update your query when you reset the id
field though unless you maybe take current epoch time + id
AS the id
field? That should always give you a new id
number that is higher than the last. Something like the following. depending on your language/product, you may have to cast it to int.
SELECT UNIX_TIMESTAMP()+RecordID AS id, * FROM dbo.test1 WHERE RecordID > ?
Edit: example was MySQL. To get epoch from PostgreSQL I believe its something like CAST(EXTRACT(epoch FROM NOW()) AS INT)
.