dpk
dpk

Reputation: 339

Update two table using store procedures

I want to update one column in table family and two column's in parent table. I know how to do it in sql. I tried it by seeing some examples, and it worked if i tried to update it in sql directly but i can't update using store procedures.

CREATE PROCEDURE prc_EditProfile(
IN inputfamilyName VARCHAR(45),
inputuserName VARCHAR(45), 
inputfamilyID INT(20),
inputparentID INT(20)
)
BEGIN
update family, parent SET family.familyName= inputfamilyName, parent.userName=inputuserName WHERE family.FamilyID=inputfamilyID AND parent.ParentID=inputfamilyID;
END

Upvotes: 0

Views: 31

Answers (1)

Adam Silenko
Adam Silenko

Reputation: 3108

Read about Update .

You can do this (to test call):

CREATE PROCEDURE prc_EditProfile(
IN inputfamilyName VARCHAR(45),
inputuserName VARCHAR(45), 
inputfamilyID INT(20),
inputparentID INT(20)
)
BEGIN
  UPDATE family 
  SET familyName= inputfamilyName
  WHERE family.FamilyID=inputfamilyID;

  UPDATE parent 
  SET userName=inputuserName 
  WHERE parent.ParentID=inputfamilyID;
END

Upvotes: 1

Related Questions