Hi! I would like to update multiple table rows with different values in a single go. I found https://stackoverflow.com/questions/18936896/updating-multiple-rows-with-different-primary-key-in-one-query-in-postgresql, but I'm not sure if it can be built using Honeysql. Any hint?
Or maybe I should just use next.jdbc/execute-batch` instead?
Is it always the same number of tables that need to be updated? The you could prepate a statement for that. If the number changes, then batch processing seems to be more suitable. What is the reason you want to update it in one go and how large is the number of rows to be updaed?
It's always the same table and fixed subset of columns.
The number of rows should be < 50
I wanted to do it in a single go thinking on performance (less round trips to the DB)
Not sure what you mean with "The you could prepate a statement for that.". Could you elaborate? thx 😄
in HoneySQL, how can one write the PostgreSQL equivalent of
last_seen BETWEEN NOW() - INTERVAL '24 Hours' AND NOW()
I tried this,
[:between :last_seen [:- [:now] [:interval 24 :Hours]] [:now]]
but got, syntax error at or near "$3"https://github.com/seancorfield/honeysql/commit/1710e072318e90d58ee434b4a6766f32d0218d25
thank you for adding this 🙂
am actually still not sure how to use it. So if i have to add interval '12 hours' should I use it like [:interval 12 :Hours] ?
That commit adds examples in documentation and tests showing how to use it.
First off, are you asking about HoneySQL v1 or v2? Second, there's a dedicated #honeysql channel, just FYI.
The syntax you say you want is INTERVAL 'some string' which I'm not sure you can create with v2 right now. The [:interval ..] syntax is somewhat MySQL specific I think...
Feel free to create an issue on GitHub and I'll update the way that is handled.
Thanks Sean!! am using v2 and I'll see if I can modify the query so I can avoid using the interval.