action.sql 293 B

12345678910111213141516171819
  1. CREATE FUNCTION `action`(
  2. a_name VARCHAR(50)
  3. ) RETURNS INT(10)
  4. DETERMINISTIC
  5. READS SQL DATA
  6. MODIFIES SQL DATA
  7. SQL SECURITY INVOKER
  8. BEGIN
  9. DECLARE t_id INT(10);
  10. INSERT IGNORE INTO actions (name)
  11. VALUES (a_name);
  12. SELECT id
  13. INTO t_id
  14. FROM actions
  15. WHERE name = a_name;
  16. return t_id;
  17. END;