How to generate the following query with update fn

51 views
Skip to first unread message

Jonathan M.

unread,
Apr 30, 2013, 10:52:13 AM4/30/13
to sqlk...@googlegroups.com
Hello,

I was wondering if it's possible to do the following query using the update fn with a MySQL server

UPDATE table SET column = column + 1;

Thank you for any replies

Jonathan 

Dennis Roberts

unread,
Apr 30, 2013, 11:22:08 AM4/30/13
to sqlk...@googlegroups.com
The only way that I've been able to find to do it so far is to use (raw):

(sql-only (update :foo (set-fields {:bar (raw "\"bar\" + 1")})))

There may be a better way to do it, but I haven't found one yet.

Dennis

--
You received this message because you are subscribed to the Google Groups "Korma" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlkorma+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jonathan M.

unread,
Apr 30, 2013, 11:39:56 AM4/30/13
to sqlk...@googlegroups.com
Thanks Dennis. I was using exec-raw up until now, good to know for the alternative thought. 

If there is an ever better way I would love to hear about it 

Michael Pheasant

unread,
Apr 30, 2013, 6:43:39 PM4/30/13
to sqlk...@googlegroups.com
Is there any way to find out how many rows were changed by an update querry?
As far as I can see update always returns nil, regardless of how many rows were updated.

m

Ryan T.

unread,
May 1, 2013, 6:11:27 AM5/1/13
to sqlk...@googlegroups.com
Good question...Unless there is a better way via the framework you can always use mysql_affected_rows with exec-raw

Some clarification would be really nice for basic things such as these.


--
You received this message because you are subscribed to a topic in the Google Groups "Korma" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlkorma/ecPL4LMmFpM/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to sqlkorma+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages