title: insert and update with stored procedure
body: <p>Have a problem with my stored procedure (on MySQL). I need the data update process of the table if the record exists, else insert the record. I have:</p>
  
  <pre><code>DELIMITER //
  
  CREATE PROCEDURE saveorUpdate(in product varchar(30), price int, stock int, active varchar(5))
  
  BEGIN
  
  DECLARE id int;
  
  SELECT id_pro FROM products WHERE product=product into id;
  
  IF(id_pro=id)THEN
  
  UPDATE products SET product=product, price=price, stock=stock, active=active 
  WHERE id_pro=id;
  
  ELSE
  
  INSERT INTO products (product, price, stock, active) VALUES 
  (product, price, stock, active);
  
  END IF;
  END
  </code></pre>
  
  <p>Any ideas?</p>