tags:

views:

36

answers:

1

hello friends

I have one table, t1, which has fileds called userid, week and year fields. I want to call a procedure which takes all three values as arguments and fires an update query. How can i do it?

My update query should be like

update t1 
    set week = (value of procedure argument) 
        , year = (value of procedure argument)
 where userid=(value of procedure argument);
+1  A: 

You can do something like this:

CREATE OR REPLACE PROCEDURE my_update_proc (w number, y number, u number) IS
BEGIN
   UPDATE t1
   SET    week = w,
          year = y
   WHERE  userid = u;
   COMMIT;
END my_update_proc;
/

Update: As @Rene has correctly pointed out, you probably do not want to have a COMMIT statement in your stored procedure. If you remove it, however, the caller must remember to commit the transaction.

klausbyskov
wow, that was easy ;-)
ammoQ
In der Beschränkung zeigt sich erst der Meister ... ;-)
Robert Merkwürdigeliebe
I would not put a commit inside a function such as this. Better to have the caller of the function decide whether or not to commit the changes
Rene
@Rene, I totally agree. But I suspected that this was the problem the OP was facing, since the question seemed very simple (to google) and it looked like he had already figured most of it out himself. I have updated the answer accordingly.
klausbyskov