DROP PROCEDURE IF EXISTS `INSERT_ELEMENT` $$
CREATE PROCEDURE `INSERT_ELEMENT`()
BEGIN
DECLARE iMod SMALLINT DEFAULT 0;
WHILE iMod<=160 DO
IF iMod<=20 THEN
INSERT INTO element VALUES ('',CONCAT('可售卖包',iMod),CONCAT('sellpackage_',iMod),'','ENABLED','SELLPACKAGE','2010-08-24 12:00:00','2010-08-25 12:00:00');
ELSEIF iMod<=40 THEN
INSERT INTO element VALUES ('',CONCAT('产品包',iMod),CONCAT('package_',iMod),'','ENABLED','PACKAGE','2010-08-24 12:00:00','2010-08-25 12:00:00');
ELSEIF iMod<=100 THEN
INSERT INTO element VALUES ('',CONCAT('产品',iMod),CONCAT('product_',iMod),'','ENABLED','PRODUCT','2010-08-24 12:00:00','2010-08-25 12:00:00');
ELSEIF iMod<=160 THEN
INSERT INTO element VALUES ('',CONCAT('功能项',iMod),CONCAT('feature_',iMod),'','ENABLED','FEATURE','2010-08-24 12:00:00','2010-08-25 12:00:00');
END IF;
SET iMod=iMod+1;
END WHILE;
COMMIT;
END $$
DELIMITER ;
CALL `INSERT_ELEMENT`();
DROP PROCEDURE IF EXISTS `INSERT_ELEMENT_REF` $$
CREATE PROCEDURE `INSERT_ELEMENT_REF`()
BEGIN
DECLARE iMod SMALLINT DEFAULT 0;
DECLARE iNum MEDIUMINT DEFAULT 1112123;
DECLARE iSell MEDIUMINT DEFAULT 1112123;
DECLARE iPackage MEDIUMINT DEFAULT 1112144;
DECLARE iProduct MEDIUMINT DEFAULT 1112164;
WHILE iMod<=160 DO
IF iMod<=20 THEN
INSERT INTO element_ref VALUES ('',iNum,'-1',NOW(),NOW());
ELSEIF iMod<=40 THEN
INSERT INTO element_ref VALUES ('',iNum,iSell,NOW(),NOW());
SET iSell=iSell+1;
ELSEIF iMod<=100 THEN
INSERT INTO element_ref VALUES ('',iNum,iPackage,NOW(),NOW());
SET iPackage=iPackage+1;
ELSEIF iMod<=160 THEN
INSERT INTO element_ref VALUES ('',iNum,iProduct,NOW(),NOW());
SET iProduct=iProduct+1;
END IF;
SET iNum=iNum+1;
SET iMod=iMod+1;
END WHILE;
COMMIT;
END $$
DELIMITER ;
CALL `INSERT_ELEMENT_REF`();
DROP PROCEDURE IF EXISTS `INSERT_FEATURE_PARAMETER` $$
CREATE PROCEDURE `INSERT_FEATURE_PARAMETER`()
BEGIN
DECLARE iMod SMALLINT DEFAULT 0;
DECLARE iNum MEDIUMINT DEFAULT 0;
DECLARE iFeatureID MEDIUMINT DEFAULT 1112224;
DECLARE iFeature MEDIUMINT DEFAULT 101;
WHILE iMod<120 DO
WHILE iNum<4 DO
IF iNum=0 THEN
INSERT INTO feature_parameter VALUES ('',iFeatureID,CONCAT('参数',iFeature),CONCAT('parameter',iFeature),'','ENABLED','INT','100','3333',NOW(),NOW());
ELSEIF iNum=1 THEN
INSERT INTO feature_parameter VALUES ('',iFeatureID,CONCAT('参数',iFeature),CONCAT('parameter',iFeature),'','ENABLED','FLOAT','96.8','3333',NOW(),NOW());
ELSEIF iNum=2 THEN
INSERT INTO feature_parameter VALUES ('',iFeatureID,CONCAT('参数',iFeature),CONCAT('parameter',iFeature),'','ENABLED','BOOLEAN','TRUE','3333',NOW(),NOW());
ELSEIF iNum=3 THEN
INSERT INTO feature_parameter VALUES ('',iFeatureID,CONCAT('参数',iFeature),CONCAT('parameter',iFeature),'','ENABLED','STRING','sellParam','3333',NOW(),NOW());
END IF;
SET iNum=iNum+1;
SET iFeature =iFeature+1;
END WHILE;
SET iNum=0;
SET iMod=iMod+1;
SET iFeatureID=iFeatureID+1;
END WHILE;
COMMIT;
END $$
DELIMITER ;
CALL `INSERT_FEATURE_PARAMETER`();
DROP PROCEDURE IF EXISTS `INSERT_SUBSCRIPTION` $$
CREATE PROCEDURE `INSERT_SUBSCRIPTION`()
BEGIN
DECLARE iloop SMALLINT DEFAULT 0;
DECLARE iMod MEDIUMINT DEFAULT 0;
DECLARE iNum MEDIUMINT DEFAULT 0;
DECLARE sellId MEDIUMINT DEFAULT 1112123;
DECLARE packageId MEDIUMINT DEFAULT 1112144;
DECLARE strMemberID VARCHAR(40) DEFAULT 0;
DECLARE Cur_account CURSOR FOR SELECT member_id FROM account;
OPEN Cur_account;
FETCH Cur_account INTO strMemberID;
WHILE iNum <= 40 DO
START TRANSACTION;
SET iloop=0;
WHILE iloop<=10 DO
SET iMod=0;
WHILE iMod < 20 DO
IF iMod < 5 THEN
INSERT INTO subscription VALUES ('',packageId,strMemberID,'START','INTL',NOW(),NOW(),CONCAT(strMemberID,'_',iMod),'ENTERPSISE',sellId);
ELSEIF iMod <10 THEN
INSERT INTO subscription VALUES ('',packageId,strMemberID,'READY','INTL',NOW(),NOW(),CONCAT(strMemberID,'_',iMod),'ENTERPSISE',sellId);
ELSEIF iMod <15 THEN
INSERT INTO subscription VALUES ('',packageId,strMemberID,'CANCEL','INTL',NOW(),NOW(),CONCAT(strMemberID,'_',iMod),'ENTERPSISE',sellId);
ELSEIF iMod < 20 THEN
INSERT INTO subscription VALUES ('',packageId,strMemberID,'END','INTL',NOW(),NOW(),CONCAT(strMemberID,'_',iMod),'ENTERPSISE',sellId);
END IF;
SET packageId = packageId+1;
SET sellId= sellId+1;
SET iMod = iMod+1;
END WHILE;
FETCH Cur_account INTO strMemberID;
SET iloop=iloop+1;
END WHILE;
COMMIT;
SET iNum=iNum+1;
END WHILE;
CLOSE Cur_account;
END $$
DELIMITER ;
CALL `INSERT_SUBSCRIPTION`();