SELECT INTO or Stored Procedure?

Posted by Kerry on Stack Overflow See other posts from Stack Overflow or by Kerry
Published on 2010-06-15T05:43:54Z Indexed on 2010/06/15 5:52 UTC
Read the original article Hit count: 288

Would this be better as a stored procedure or leave it as is?

INSERT INTO `user_permissions` 
    ( `user_id`, `object_id`, `type`, `view`, `add`, `edit`, `delete`, `admin`, `updated_by_user_id` ) 
    SELECT `user_id`, $object_id, '$type', 1, 1, 1, 1, 1, $user_id 
    FROM `user_permissions` 
    WHERE `object_id` = $object_id_2 AND `type` = '$type_2' AND `admin` = 1

You can think of this with different objects, lets say you have groups and subgroups. If someone creates a subgroup, it is making everyone who had access to the parent group now also have access to the subgroup.

I've never made a stored procedure before, but this looks like it might be time. This call be probably be called very often.

Should I be creating a procedure or will the performance be insignificant?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql