can anyone tell how to use stored procedure in mysql database to insert and update same table? -


can tell how use stored procedure in mysql database insert , update same table?

 create procedure inst_upd_pro(in product varchar(50),price int(30),stock   int(30),active int (30))  begin   declare id int;   select id_pro id products;   if(id_pro=id)then   update products set product=product, price=price, stock=stock,    active=active   id_pro=id;   else   insert products (product, price, stock, active) values   (product, price, stock, active);   end if; 

for clarity , avoid confusion (for , mysql) name incoming parameters prefix of in_ , declared variables dec. select incorrect - should looking specific product (that in in parameter) , if condition incorrect should comparing declared variable in parameter.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -