Topic
1 reply Latest Post - ‏2013-10-17T14:15:17Z by Amyris
robbiii
robbiii
2 Posts
ACCEPTED ANSWER

Pinned topic Stored Procedure with multiple where condition

‏2013-10-17T09:16:00Z |

Hello Users

Usually I write scripts and sometimes I execute easy SQL queries, but now I have to implement a stored procedure,
which is very difficult to me.

I have a table which Looks like this

NAME CHAR(32)
YEARMONTH CHAR(7)
USERCOMMENT CHAR(16)

What I want to do is, execute the sp with the Parameters NAME, YEARMONTH, COMMENT and update the table column USERCOMMENT for the desired NAME, YEARMONTH

Now I have wirtten the  following sp which works fine and update the USERCOMMENT, but If I try to replace the static values in the where clause, it happens that all table items where updated with the user comment.

Have I anything to do that the sp accepts the other Parameters too?

 

Another question is, what does it mean that a sp Returns a result set?
Should I execute a simple select Statement with the Parameters at the end?

 

Thanks for your help

Rob

CREATE PROCEDURE UPDATE_COMMENT
 (IN YEARMONT CHAR(7),
  IN NAME CHAR(32),
  IN USERCOMMENT CHAR(16))

 LANGUAGE SQL
 MODIFIES SQL DATA
 
 BEGIN
 IF USERCOMMENT != '' THEN
   UPDATE AAA_COMMENTS
    SET USERCOMMENT = USERCOMMENT
    WHERE YEARMONTH = '2013-08' and NAME = 'Application1';
 END IF;
 END
 @