将此SQL查询与计算和表更新转换为存储过程

Could someone assist in converting this query into a stored procedure for MySQL.

The Query is as follows >

UPDATE
    `2015-06`
SET
    `Cost`=(
                CEIL(
                        `DurationMin`*65.00
                    )/100
            ),
    `Location`='New Caledonia - Mobile'
WHERE
    `Cost` IS NULL

    AND

    SUBSTR(
            `Dialed`,
            1,
            8
    ) = '01168779'

Briefly explained, this query is run multiple times with the following parameters that change (explained)

2015-06 == This is the Month.
65.00 == This is the Amount per minute charge. I divide by 100 as the DB has some weird float issues that crop up otherwise so the pennies are stored as whole numbers without decimal.
New Caledonia - Mobile == This is the location string.
01168779 == The first (in this case 8) digits to check for.

The SUBSTR, gets the first X number of digits from the Dialed field. The number (in this case 8) needs to be a parameter as well.

Pseudo-code for the resulting stored procedure or function (i get confused between the two), is as follows (how i imagine it should be)

Foo(
     <varchar> TableName, # In the above example, the `2015-06` position
     <int> Amount, # In the above example, the `65.00` position
     <varchar> Location, # ... `New Caledonia - Mobile` position
     <int> DigitLength, # The 3rd param in the SUBSTR
     <varchar> Digits # Using the above example this would be the `01168779` position.
);

The problem is that these queries also must run in sequential order (currently using a PHP script to call them which is working perfectly, but each query is taking some time to complete. No real way I can see to speed this up but I welcome optimizations if possible.