Mark, thanks for the insight. It's not code-writing-code. Rather it's code reading a "*.sproc" file which is just the stored procedure SQL file renamed so I can differentiate between regular SQL and the stored procedures.
As far as creating a script that runs these files, what would you suggest? Would the above work or is there something better? When I go to use the above script, I would execute the following queries in order:
DELIMITER |
DROP PROCEDURE IF EXISTS addBoycott;|
CREATE PROCEDURE addBoycott (IN orgID SMALLINT,IN userID SMALLINT,IN boycottName VARCHAR(60),IN boycottDesc LONGTEXT,IN endDate Date, IN goalAmount SMALLINT, IN invitationMessage LONGTEXT, IN thankyouMessage LONGTEXT, IN recipientFormalName TEXT, IN recipientEmail TEXT, IN instructions LONGTEXT, IN messageSubject TEXT, IN messageHeader LONGTEXT, IN messageBody LONGTEXT, IN messageFooter LONGTEXT, IN talkingPoints TEXT, OUT boycottID SMALLINT)
BEGIN
DECLARE error_msg TEXT;
DECLARE lineageID SMALLINT;
DECLARE campaignID SMALLINT;
DECLARE userCampaignID SMALLINT;
DECLARE `Constraint Violation`
CONDITION FOR SQLSTATE '23000';
DECLARE EXIT HANDLER FOR
`Constraint Violation` ROLLBACK;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
START TRANSACTION;
INSERT INTO `boycott` (`org_id`, `user_id`, `name`, `description`, `end_date`, `goal_amount`, `invitation_message`, `thankyou_message`, `recipient_formal_name`, `recipient_email`, `instructions`, `message_subject`, `message_header`, `message_body`, `message_footer`, `talking_points`)
VALUES (orgID, userID, boycottName, boycottDesc, endDate, goalAmount, invitationMessage, thankyouMessage, recipientFormalName, recipientEmail, instructions, messageSubject, messageHeader, messageBody, messageFooter, talkingPoints);
SET boycottID = last_insert_id();
CALL addBoycottLineage(userID, boycottID, userID, lineageID);
INSERT INTO `campaign` (`fk_id`, `type_id`, `name`)
VALUES (boycottID, 1, boycottName);
SET campaignID = last_insert_id();
CALL addUserCampaign (userID, campaignID, goalAmount, userID, userCampaignID);
COMMIT;
END|
Now that's done multiple times (with the delimiter changing at the beginning and end of every file). Of course, I'm doing those through the [man]mysql_query/man call.... should i just be using: [man]exec[/man]('mysql ' . $current_query); instead ?