2012-01-09 137 views
0

我想給如果條件在我的程序,但創建問題,請幫助我。這個程序出了什麼問題?

DELIMITER $$ 

DROP PROCEDURE IF EXISTS `fill_plan_data`$$ 
CREATE PROCEDURE `fill_plan_data`(IN statecode VARCHAR(2), carrier_name VARCHAR(50)) 
    BEGIN 
    DECLARE countMedicaid int default 0; 
    insert into carrier (`name`,`state_code`,`active`,`carrier_id`) select CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name from 2))), upper(statecode), '1', upper(concat_ws('-',carrier_name,statecode)) from (select distinct `state_code` from zip_codes)t where state_code = upper(statecode); 
    select count(*) into countMedicaid from plan_details p , carrier c where c.name = carrier_name and c.state_code = statecode and c.id = p.carrier_id and p.programType = 'medicaid'; 
    if countMedicaid == 0 then 
     //then do some insert query 
    end if 

    insert into plan_details (`name`,`plan_type`,`carrier_id`,benefits,active,active_from,active_to,created_by,created_date,updated_by,updated_date,plan_id,market_code,family_code,available_for,level_of_coverage,customer_rating,quality_rating,`type`) select concat(`name`,' Simple 2'), '0', id,'<?xml version=\"1.0\" encoding=\"UTF-8\"?><planBenefits lifeTimeMaximum_outnw=\"0.0\" lifeTimeMaximum_innw=\"0.0\" mailOrderDaysSupply_innw=\"90.0\" mailOrderDaysSupply_outnw=\"0.0\"><pcpRequired_innw value=\"true\"/><pcpRequired_outnw/><srRequired_innw value=\"true\"/><srRequired_outnw/><hsaEligible_innw value=\"true\"/><hsaEligible_outnw/><outOfNetworkCoverage_innw value=\"false\"/><outOfCountryCoverage_innw/><outOfCountryCoverage_outnw/><adminFees_innw payableWhen=\"ONE_TIME\" amount=\"50.0\"/><adminFees_outnw payableWhen=\"NONE\" amount=\"0.0\"/><deductible_innw applicable=\"true\" individual_amt=\"1000.0\" family_amt=\"2000.0\" displayString=\"\"/><deductible_outnw applicable=\"true\" individual_amt=\"10000.0\" family_amt=\"20000.0\"/><coinsurance_innw applicable=\"true\" amount=\"40.0\" beforeDeductible=\"true\"/><coinsurance_outnw applicable=\"true\" amount=\"50.0\" beforeDeductible=\"true\"/><outOfPocketLimit_innw applicable=\"true\" individual_amt=\"2000\" family_amt=\"4000\" /><outOfPocketLimit_outnw applicable=\"true\" individual_amt=\"12500.0\" family_amt=\"25000.0\"/><primaryDoctor_innw covered=\"true\" copay=\"20.0\"/><primaryDoctor_outnw covered=\"true\"/><specialist_innw covered=\"true\" copay=\"20.0\"/><specialist_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><periodicHealthExam_innw covered=\"false\" copay=\"0.0\"/><periodicHealthExam_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><periodicObGynExam_innw covered=\"false\" copay=\"0.0\"/><periodicObGynExam_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><wellBabyCare_innw covered=\"false\" copay=\"0.0\"/><wellBabyCare_outnw covered=\"true\" copay=\"50.0\"/><chiropractic_innw covered=\"true\" coinsuranceAfterDeductible=\"40.0\" displayString=\"Max 5 outpatient visits per benefit year\"/><chiropractic_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><mentalHealth_innw covered=\"false\" coinsuranceAfterDeductible=\"0.0\" displayString=\"Limited to Biologically Based Mental Illness/Copayment or coinsurance/Deductible is depending on place of service.\"/><mentalHealth_outnw covered=\"true\" coinsuranceBeforeDeductible=\"0.0\"/><genericPrescriptionDrugs_innw covered=\"true\" copay=\"15.0\" displayString=\"\"/><genericPrescriptionDrugs_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\" displayString=\"or 50%, whichever is greater \"/><brandedPrescriptionDrugs_innw covered=\"true\" copay=\"30.0\" displayString=\"\"/><brandedPrescriptionDrugs_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\" displayString=\"or 50%, whichever is greater \"/><nonFormulatoryPrescriptionDrugs_innw covered=\"true\" copay=\"50.0\" displayString=\"\"/><nonFormulatoryPrescriptionDrugs_outnw covered=\"true\" copay=\"50.0\"/><annualPrescriptionDrugs_innw applicable=\"false\" individual_amt=\"0.0\" family_amt=\"0.0\"/><anuualPrescriptionDrugs_outnw applicable=\"true\" individual_amt=\"50.0\" family_amt=\"101.0\"/><genericMailOrder_innw covered=\"true\" copay=\"30.0\" displayString=\"\"/><genericMailOrder_outnw covered=\"true\" copay=\"80.0\" displayString=\"or 50%, whichever is greater \"/><brandedMailOrder_innw covered=\"true\" copay=\"60.0\" displayString=\"\"/><brandedMailOrder_outnw covered=\"true\" copay=\"500.0\" displayString=\"or 50%, whichever is greater \"/><nonFormulatoryMailOrder_innw covered=\"true\" copay=\"150.0\" displayString=\"\"/><nonFormulatoryMailOrder_outnw covered=\"true\" coinsuranceBeforeDeductible=\"80.0\"/><annualMailOrder_innw applicable=\"false\" individual_amt=\"0.0\" family_amt=\"0.0\" displayString=\"None\"/><annualMailOrder_outnw applicable=\"true\" individual_amt=\"50.0\" family_amt=\"101.0\"/><labsAndXRays_innw covered=\"true\" copay=\"0.0\" displayString=\"Copay after deductible\"/><labsAndXRays_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><emergencyRoom_innw covered=\"true\" copay=\"100.0\" displayString=\"Copay after deductible\"/><emergencyRoom_outnw covered=\"true\" copay=\"50.0\"/><outpatientSurgery_innw covered=\"true\" copay=\"0.0\" displayString=\"Copay after deductible\"/><outpatientSurgery_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><hospitalization_innw covered=\"true\" copay=\"0.0\" displayString=\"Copay after deductible\"/><hospitalization_outnw covered=\"true\" coinsuranceAfterDeductible=\"5000.0\"/><preAndPostNatalOfficeVisit_innw covered=\"false\"/><preAndPostNatalOfficeVisit_outnw covered=\"true\" displayString=\"Complications Only\"/><laborDeliveryHospitalStay_innw covered=\"false\"/><laborDeliveryHospitalStay_outnw covered=\"false\" displayString=\"Complications Only\"/><mailOrderAvailable_innw value=\"true\"/><mailOrderAvailable_outnw/><preventiveCare_innw value=\"true\"/><preventiveCare_outnw value=\"true\"/><benefitsUrls><benefits url=\"http://www.electroluxicon.com/Files/International_English/0-999/documents/E24CM76GSS_UC.pdf\"/><benefits url=\"http://www.sedl.org/scimath/pasopartners/pdfs/health.pdf\"/><benefits url=\"CovOne EG 09-10.pdf\" displayText=\"Plan Brochure\"/></benefitsUrls><officeVisits_innw value=\"true\"/><officeVisits_outnw value=\"true\"/><prescriptionDrugBenefit_innw value=\"true\"/><prescriptionDrugBenefit_outnw value=\"true\"/><hospitalServices_innw value=\"true\"/><hospitalServices_outnw value=\"true\"/><maternity_innw value=\"true\"/><maternity_outnw value=\"true\"/><addlCoverage_innw value=\"true\"/><addlCoverage_outnw value=\"true\"/></planBenefits>',1,'2009-01-10','2012-01-03','[email protected]',CURRENT_TIMESTAMP(),null,null,concat(carrier_id,'SIMPLE_2'),concat(`name`,'_market_code'),'Simple',0,'silver',5,4,0 from carrier where carrier.state_code=upper(statecode) and carrier.name=carrier_name; 
    insert into plan_details (`name`,`plan_type`,`carrier_id`,benefits,active,active_from,active_to,created_by,created_date,updated_by,updated_date,plan_id,market_code,family_code,available_for,level_of_coverage,customer_rating,quality_rating,`type`) select concat(`name`,' Simple 3'), '0', id, '<?xml version=\"1.0\" encoding=\"UTF-8\"?><planBenefits lifeTimeMaximum_outnw=\"0.0\" lifeTimeMaximum_innw=\"0.0\" mailOrderDaysSupply_innw=\"90.0\" mailOrderDaysSupply_outnw=\"0.0\"><pcpRequired_innw value=\"true\"/><pcpRequired_outnw/><srRequired_innw value=\"true\"/><srRequired_outnw/><hsaEligible_innw value=\"true\"/><hsaEligible_outnw/><outOfNetworkCoverage_innw value=\"false\"/><outOfCountryCoverage_innw/><outOfCountryCoverage_outnw/><adminFees_innw payableWhen=\"ONE_TIME\" amount=\"50.0\"/><adminFees_outnw payableWhen=\"NONE\" amount=\"0.0\"/><deductible_innw applicable=\"false\" individual_amt=\"0.0\" family_amt=\"0.0\" displayString=\"None\"/><deductible_outnw applicable=\"true\" individual_amt=\"10000.0\" family_amt=\"20000.0\"/><coinsurance_innw applicable=\"true\" amount=\"40.0\" beforeDeductible=\"true\"/><coinsurance_outnw applicable=\"true\" amount=\"50.0\" beforeDeductible=\"true\"/><outOfPocketLimit_innw applicable=\"true\" individual_amt=\"2000\" family_amt=\"4000\" /><outOfPocketLimit_outnw applicable=\"true\" individual_amt=\"12500.0\" family_amt=\"25000.0\"/><primaryDoctor_innw covered=\"true\" copay=\"25.0\"/><primaryDoctor_outnw covered=\"true\"/><specialist_innw covered=\"true\" copay=\"40.0\"/><specialist_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><periodicHealthExam_innw covered=\"false\" copay=\"0.0\"/><periodicHealthExam_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><periodicObGynExam_innw covered=\"false\" copay=\"0.0\"/><periodicObGynExam_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><wellBabyCare_innw covered=\"false\" copay=\"0.0\"/><wellBabyCare_outnw covered=\"true\" copay=\"50.0\"/><chiropractic_innw covered=\"true\" coinsuranceAfterDeductible=\"40.0\" displayString=\"Max 5 outpatient visits per benefit year\"/><chiropractic_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\"/><mentalHealth_innw covered=\"false\" coinsuranceAfterDeductible=\"0.0\" displayString=\"Limited to Biologically Based Mental Illness/Copayment or coinsurance/Deductible is depending on place of service.\"/><mentalHealth_outnw covered=\"true\" coinsuranceBeforeDeductible=\"0.0\"/><genericPrescriptionDrugs_innw covered=\"true\" copay=\"15.0\" displayString=\"\"/><genericPrescriptionDrugs_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\" displayString=\"or 50%, whichever is greater \"/><brandedPrescriptionDrugs_innw covered=\"true\" copay=\"50.0\" displayString=\"\"/><brandedPrescriptionDrugs_outnw covered=\"true\" coinsuranceAfterDeductible=\"0.0\" displayString=\"or 50%, whichever is greater \"/><nonFormulatoryPrescriptionDrugs_innw covered=\"true\" coinsuranceAfterDeductible=\"50.0\" displayString=\"\"/><nonFormulatoryPrescriptionDrugs_outnw covered=\"true\" copay=\"50.0\"/><annualPrescriptionDrugs_innw applicable=\"false\" individual_amt=\"0.0\" family_amt=\"0.0\"/><anuualPrescriptionDrugs_outnw applicable=\"true\" individual_amt=\"50.0\" family_amt=\"101.0\"/><genericMailOrder_innw covered=\"true\" copay=\"30.0\" displayString=\"\"/><genericMailOrder_outnw covered=\"true\" copay=\"80.0\" displayString=\"or 50%, whichever is greater \"/><brandedMailOrder_innw covered=\"true\" coinsuranceAfterDeductible=\"50.0\" displayString=\"\"/><brandedMailOrder_outnw covered=\"true\" copay=\"500.0\" displayString=\"or 50%, whichever is greater \"/><nonFormulatoryMailOrder_innw covered=\"true\" coinsuranceAfterDeductible=\"50.0\" displayString=\"\"/><nonFormulatoryMailOrder_outnw covered=\"true\" coinsuranceBeforeDeductible=\"80.0\"/><annualMailOrder_innw applicable=\"false\" individual_amt=\"0.0\" family_amt=\"0.0\" displayString=\"None\"/><annualMailOrder_outnw applicable=\"true\" individual_amt=\"50.0\" family_amt=\"101.0\"/><labsAndXRays_innw covered=\"true\" copay=\"0.0\"/><labsAndXRays_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><emergencyRoom_innw covered=\"true\" copay=\"100.0\"/><emergencyRoom_outnw covered=\"true\" copay=\"50.0\"/><outpatientSurgery_innw covered=\"true\" copay=\"500.0\"/><outpatientSurgery_outnw covered=\"true\" coinsuranceAfterDeductible=\"50.0\"/><hospitalization_innw covered=\"true\" copay=\"500.0\"/><hospitalization_outnw covered=\"true\" coinsuranceAfterDeductible=\"5000.0\"/><preAndPostNatalOfficeVisit_innw covered=\"false\"/><preAndPostNatalOfficeVisit_outnw covered=\"true\" displayString=\"Complications Only\"/><laborDeliveryHospitalStay_innw covered=\"false\"/><laborDeliveryHospitalStay_outnw covered=\"false\" displayString=\"Complications Only\"/><mailOrderAvailable_innw value=\"true\"/><mailOrderAvailable_outnw/><preventiveCare_innw value=\"true\"/><preventiveCare_outnw value=\"true\"/><benefitsUrls><benefits url=\"http://www.electroluxicon.com/Files/International_English/0-999/documents/E24CM76GSS_UC.pdf\"/><benefits url=\"http://www.sedl.org/scimath/pasopartners/pdfs/health.pdf\"/><benefits url=\"CovOne EG 09-10.pdf\" displayText=\"Plan Brochure\"/></benefitsUrls><officeVisits_innw value=\"true\"/><officeVisits_outnw value=\"true\"/><prescriptionDrugBenefit_innw value=\"true\"/><prescriptionDrugBenefit_outnw value=\"true\"/><hospitalServices_innw value=\"true\"/><hospitalServices_outnw value=\"true\"/><maternity_innw value=\"true\"/><maternity_outnw value=\"true\"/><addlCoverage_innw value=\"true\"/><addlCoverage_outnw value=\"true\"/></planBenefits>',1,'2009-01-10','2012-01-03','[email protected]',CURRENT_TIMESTAMP(),null,null,concat(carrier_id,'SIMPLE_3'),concat(`name`,'_market_code'),'Simple',0,'gold',4,5,0 from carrier where carrier.state_code=upper(statecode) and carrier.name=carrier_name; 

    insert into plan_documents (select plan_id, market_code, active_from, ExtractValue(benefits,'/planBenefits/benefitsUrls/benefits[@displayText="Additional Details"]/@url'), ExtractValue(benefits,'/planBenefits/benefitsUrls/benefits[@displayText="Plan Brochure"]/@url'), ExtractValue(benefits,'/planBenefits/benefitsUrls/benefits[@displayText="Exclusions and Limitations"]/@url'), null, CURRENT_TIMESTAMP() from plan_details where plan_id like concat('%',carrier_name,'-',statecode , '%')); 
    insert into plan_service_area_lookup select `code`,`county`,CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name from 2)),'_Region_Code'),CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name from 2)),'_Region_Desc'),CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name FROM 2)),'_Market_Code'),upper(concat_ws('-',carrier_name,statecode)) from zip_codes where state_code = upper(statecode); 
    insert into area_code_lookup select `code`,`county`,CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name from 2)),'_Region_Code'),CONCAT(UPPER(SUBSTRING(carrier_name, 1, 1)), LOWER(SUBSTRING(carrier_name from 2)),'_Region_Desc'),upper(concat_ws('-',carrier_name,statecode)) from zip_codes where state_code = upper(statecode); 

    END$$ 

請幫我出了什麼問題,如果條件?如果要是條件程序執行成功

DELIMITER ; 

回答

2

的我刪除「等於」運算符SQL只是=,不==。您的MySQL客戶端應該顯示錯誤消息。

+0

「你的MySQL客戶端應該顯示錯誤信息」---閱讀錯誤信息很無聊。在沒有重要細節的情況下提出SO問題更加有趣:-) – zerkms 2012-01-09 10:37:19

+0

...並添加';'在'end if'條款之後。 – Devart 2012-01-09 10:38:38