I have a basic table that looks like the following:
SQL> desc comments
Name Null? Type
---------------------------------------
COMMENT_ID NOT NULL NUMBER
POST_ID NOT NULL NUMBER
USER_ID NOT NULL NUMBER
MESSAGE NOT NULL VARCHAR2(2500)
MESSAGE_TIME NOT NULL TIMESTAMP(6)
UPVOTES NOT NULL NUMBER
What I’d like to do is have a stored procedure be called that would increment the upvotes. This seems to make the most sense because I don’t want to pass in anything other than the comment_id and post_id.
I think I should be doing something like this (please excuse syntax, I haven’t messed with stored procedures in a long long time)
CREATE OR REPLACE procedure proc_upvote_comment (comment_id NUMBER , post_id NUMBER)
BEGIN
SELECT UPVOTES FROM COMMENTS
WHERE COMMENTS.COMMENT_ID = proc_upvote_comment.comment_id
AND COMMENTS.POST_ID = proc_upvote_comment.post_id;
//Call an update
END;
/
But I just don’t seem to know the missing piece here. I’ve tried looking at
http://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#i1007682
http://docs.oracle.com/cd/B12037_01/server.101/b10759/statements_6009.htm
And a few other places on the site – but I’m just missing something.
Any help in the right direction would be great
Is there any reason this is not working for you:
Remember that SQL works with sets 😉