更改数据库结构后更新旧存储过程
Updating old stored procedure after changing database structure
我正在更新获取 _POST 信息并将其保存到 MySQL 数据库的存储过程。 table 的结构发生了变化;某些属性已从 TINYINT(0,1) 更改为 ENUM(Yes/No).
但是,当我更改程序以反映这一点时,我收到了解析错误。这意味着我的新声明写错了。我不确定我是怎么弄错的。
代码在这里:
DROP PROCEDURE IF EXISTS DSSv3_SummaryInfo_insertPostInfo;
DELIMITER //
CREATE PROCEDURE DSSv3_SummaryInfo_insertPostInfo(
IN InProjectID INT,
IN InTimeframe VARCHAR(25),
IN InDateSpent VARCHAR(3000),
IN InDateSpentDesc VARCHAR(3000),
IN InQaName INT,
IN InWhyStoreDesc TEXT,
IN InChannelTypeDesc TEXT,
IN InOtherEntitiesDesc TEXT,
IN InNetworkDiagramDesc TEXT,
IN InScopingMethods TEXT,
IN InScopingConfirmationMethods TEXT,
IN InScopingMethodEvaluation TEXT,
IN InScopingMethodDocumentation TEXT,
IN InScopingMethodAccuracy TEXT,
IN InScopingAssessorName INT,
IN InEnvironmentPeople TEXT,
IN InEnvironmentProcesses TEXT,
IN InEnvironmentTechnologies TEXT,
IN InEnvironmentLocations TEXT,
IN InEnvironmentOther TEXT,
IN InSegmentationUsed ENUM,
IN InNoSegmentationAssessor INT,
IN InSegmentationHow TEXT,
IN InSegmentationTechnologies TEXT,
IN InSegmentationValidate TEXT,
IN InSegmentationFunction TEXT,
IN InSegmentationIntegrity TEXT,
IN InWithSegmentationAssessor INT,
IN InCountriesEntityConductsBusiness TEXT,
IN InWirelessVerify TEXT,
IN InWirelessImpact TEXT,
IN InSamplingNotUsedAssessor INT,
IN InSamplingUsedAssessor INT,
IN InSamplingRational TEXT,
IN InSamplingStandardiseControl TEXT,
IN InSamplingControlValidation TEXT,
IN InThirdPartyAssessorPadss INT,
IN InThirdPartyAssessorP2pe INT,
IN InThirdPartyScopeReduction TEXT,
IN InThirdPartyComments TEXT,
IN InSpIsSp TINYINT,
IN InSpIncludedRequirements VARCHAR(3000),
IN InSpExcludedRequirements VARCHAR(3000),
IN InSpAssessor INT,
IN InSpIpAddr VARCHAR(1500),
IN InSpCustomerIpAddr VARCHAR(1500),
IN InQsInitial TINYINT,
IN InQsAmount TINYINT,
IN InQsPassAssessor INT,
IN InQsDocumentAssessor TEXT,
IN InQsCorrection TEXT,
IN InQsAssessorComments TEXT,
IN InQsAocAssessor TEXT
)
BEGIN
/*
set all _POST data for executive summary
InParam:
All _POST data variables on executive summary form
Excludes _FILES data
*/
IF NOT EXISTS (SELECT 1 FROM SummaryInfo WHERE ProjectID = InProjectID) THEN
INSERT INTO SummaryInfo(
ProjectID,
timeframe,
date_spent,
date_spent_desc,
qa_name,
why_store_desc,
channel_type_desc,
other_entities_desc,
network_diagram_desc,
scoping_methods,
scoping_confirmation_methods,
scoping_method_evaluation,
scoping_method_documentation,
scoping_method_accuracy,
scoping_assessor_name,
environment_people,
environment_processes,
environment_technologies,
environment_locations,
environment_other,
segmentation_used,
no_segmentation_assessor,
segmentation_how,
segmentation_technologies,
segmentation_validate,
segmentation_function,
segmentation_integrity,
with_segmentation_assessor,
countries_entity_conducts_business,
wireless_verify,
wireless_impact,
sampling_not_used_assessor,
sampling_used_assessor,
sampling_rational,
sampling_standardise_control,
sampling_control_validation,
third_party_assessor_padss,
third_party_assessor_p2pe,
third_party_scope_reduction,
third_party_comments,
sp_is_sp,
sp_included_requirements,
sp_excluded_requirements,
sp_assessor,
sp_ip_addr,
sp_customer_ip_addr,
qs_initial,
qs_amount,
qs_pass_assessor,
qs_document_assessor,
qs_correction,
qs_assessor_comments,
qs_aoc_assessor
)
VALUES (
InProjectID,
InTimeframe,
InDateSpent,
InDateSpentDesc,
InQaName,
InWhyStoreDesc,
InChannelTypeDesc,
InOtherEntitiesDesc,
InNetworkDiagramDesc,
InScopingMethods,
InScopingConfirmationMethods,
InScopingMethodEvaluation,
InScopingMethodDocumentation,
InScopingMethodAccuracy,
InScopingAssessorName,
InEnvironmentPeople,
InEnvironmentProcesses,
InEnvironmentTechnologies,
InEnvironmentLocations,
InEnvironmentOther,
InSegmentationUsed,
InNoSegmentationAssessor,
InSegmentationHow,
InSegmentationTechnologies,
InSegmentationValidate,
InSegmentationFunction,
InSegmentationIntegrity,
InWithSegmentationAssessor,
InCountriesEntityConductsBusiness,
InWirelessVerify,
InWirelessImpact,
InSamplingNotUsedAssessor,
InSamplingUsedAssessor,
InSamplingRational,
InSamplingStandardiseControl,
InSamplingControlValidation,
InThirdPartyAssessorPadss,
InThirdPartyAssessorP2pe,
InThirdPartyScopeReduction,
InThirdPartyComments,
InSpIsSp,
InSpIncludedRequirements,
InSpExcludedRequirements,
InSpAssessor,
InSpIpAddr,
InSpCustomerIpAddr,
InQsInitial,
InQsAmount,
InQsPassAssessor,
InQsDocumentAssessor,
InQsCorrection,
InQsAssessorComments,
InQsAocAssessor
);
ELSE
UPDATE SummaryInfo SET
timeframe = InTimeframe,
date_spent = InDateSpent,
date_spent_desc = InDateSpentDesc,
qa_name = InQaName,
why_store_desc = InWhyStoreDesc,
channel_type_desc = InChannelTypeDesc,
other_entities_desc = InOtherEntitiesDesc,
network_diagram_desc = InNetworkDiagramDesc,
scoping_methods = InScopingMethods,
scoping_confirmation_methods = InScopingConfirmationMethods,
scoping_method_evaluation = InScopingMethodEvaluation,
scoping_method_documentation = InScopingMethodDocumentation,
scoping_method_accuracy = InScopingMethodAccuracy,
scoping_assessor_name = InScopingAssessorName,
environment_people = InEnvironmentPeople,
environment_processes = InEnvironmentProcesses,
environment_technologies = InEnvironmentTechnologies,
environment_locations = InEnvironmentLocations,
environment_other = InEnvironmentOther,
segmentation_used = InSegmentationUsed,
no_segmentation_assessor = InNoSegmentationAssessor,
segmentation_how = InSegmentationHow,
segmentation_technologies = InSegmentationTechnologies,
segmentation_validate = InSegmentationValidate,
segmentation_function = InSegmentationFunction,
segmentation_integrity = InSegmentationIntegrity,
with_segmentation_assessor = InWithSegmentationAssessor,
countries_entity_conducts_business = InCountriesEntityConductsBusiness,
wireless_verify = InWirelessVerify,
wireless_impact = InWirelessImpact,
sampling_not_used_assessor = InSamplingNotUsedAssessor,
sampling_used_assessor = InSamplingUsedAssessor,
sampling_rational = InSamplingRational,
sampling_standardise_control = InSamplingStandardiseControl,
sampling_control_validation = InSamplingControlValidation,
third_party_assessor_padss = InThirdPartyAssessorPadss,
third_party_assessor_p2pe = InThirdPartyAssessorP2pe,
third_party_scope_reduction = InThirdPartyScopeReduction,
third_party_comments = InThirdPartyComments,
sp_is_sp = InSpIsSp,
sp_included_requirements = InSpIncludedRequirements,
sp_excluded_requirements = InSpExcludedRequirements,
sp_assessor = InSpAssessor,
sp_ip_addr = InSpIpAddr,
sp_customer_ip_addr = InSpCustomerIpAddr,
qs_initial = InQsInitial,
qs_amount = InQsAmount,
qs_pass_assessor = InQsPassAssessor,
qs_document_assessor = InQsDocumentAssessor,
qs_correction = InQsCorrection,
qs_assessor_comments = InQsAssessorComments,
qs_aoc_assessor = InQsAocAssessor
WHERE
ProjectID = InProjectID;
END IF;
END//
DELIMITER ;
错误信息:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN InNoSegmentationAssessor INT,IN InSegmentationH' at line 22
当我像结构更改之前一样将 ENUM 改回 INT 时,存储过程加载时没有错误。但是它当然不会工作,因为它与数据库的结构不匹配。
我一直在寻找答案,但我清楚地知道在这个特定情况下我首先做错了什么。任何提示或建议都会很好。
是的,这是一个庞大的过程。它是遗留代码。是的,它是一个枚举。就是出报告。
声明 ENUM
时,您必须指定值。所以应该是:
IN InSegmentationUsed ENUM('Yes', 'No'),
我正在更新获取 _POST 信息并将其保存到 MySQL 数据库的存储过程。 table 的结构发生了变化;某些属性已从 TINYINT(0,1) 更改为 ENUM(Yes/No).
但是,当我更改程序以反映这一点时,我收到了解析错误。这意味着我的新声明写错了。我不确定我是怎么弄错的。
代码在这里:
DROP PROCEDURE IF EXISTS DSSv3_SummaryInfo_insertPostInfo;
DELIMITER //
CREATE PROCEDURE DSSv3_SummaryInfo_insertPostInfo(
IN InProjectID INT,
IN InTimeframe VARCHAR(25),
IN InDateSpent VARCHAR(3000),
IN InDateSpentDesc VARCHAR(3000),
IN InQaName INT,
IN InWhyStoreDesc TEXT,
IN InChannelTypeDesc TEXT,
IN InOtherEntitiesDesc TEXT,
IN InNetworkDiagramDesc TEXT,
IN InScopingMethods TEXT,
IN InScopingConfirmationMethods TEXT,
IN InScopingMethodEvaluation TEXT,
IN InScopingMethodDocumentation TEXT,
IN InScopingMethodAccuracy TEXT,
IN InScopingAssessorName INT,
IN InEnvironmentPeople TEXT,
IN InEnvironmentProcesses TEXT,
IN InEnvironmentTechnologies TEXT,
IN InEnvironmentLocations TEXT,
IN InEnvironmentOther TEXT,
IN InSegmentationUsed ENUM,
IN InNoSegmentationAssessor INT,
IN InSegmentationHow TEXT,
IN InSegmentationTechnologies TEXT,
IN InSegmentationValidate TEXT,
IN InSegmentationFunction TEXT,
IN InSegmentationIntegrity TEXT,
IN InWithSegmentationAssessor INT,
IN InCountriesEntityConductsBusiness TEXT,
IN InWirelessVerify TEXT,
IN InWirelessImpact TEXT,
IN InSamplingNotUsedAssessor INT,
IN InSamplingUsedAssessor INT,
IN InSamplingRational TEXT,
IN InSamplingStandardiseControl TEXT,
IN InSamplingControlValidation TEXT,
IN InThirdPartyAssessorPadss INT,
IN InThirdPartyAssessorP2pe INT,
IN InThirdPartyScopeReduction TEXT,
IN InThirdPartyComments TEXT,
IN InSpIsSp TINYINT,
IN InSpIncludedRequirements VARCHAR(3000),
IN InSpExcludedRequirements VARCHAR(3000),
IN InSpAssessor INT,
IN InSpIpAddr VARCHAR(1500),
IN InSpCustomerIpAddr VARCHAR(1500),
IN InQsInitial TINYINT,
IN InQsAmount TINYINT,
IN InQsPassAssessor INT,
IN InQsDocumentAssessor TEXT,
IN InQsCorrection TEXT,
IN InQsAssessorComments TEXT,
IN InQsAocAssessor TEXT
)
BEGIN
/*
set all _POST data for executive summary
InParam:
All _POST data variables on executive summary form
Excludes _FILES data
*/
IF NOT EXISTS (SELECT 1 FROM SummaryInfo WHERE ProjectID = InProjectID) THEN
INSERT INTO SummaryInfo(
ProjectID,
timeframe,
date_spent,
date_spent_desc,
qa_name,
why_store_desc,
channel_type_desc,
other_entities_desc,
network_diagram_desc,
scoping_methods,
scoping_confirmation_methods,
scoping_method_evaluation,
scoping_method_documentation,
scoping_method_accuracy,
scoping_assessor_name,
environment_people,
environment_processes,
environment_technologies,
environment_locations,
environment_other,
segmentation_used,
no_segmentation_assessor,
segmentation_how,
segmentation_technologies,
segmentation_validate,
segmentation_function,
segmentation_integrity,
with_segmentation_assessor,
countries_entity_conducts_business,
wireless_verify,
wireless_impact,
sampling_not_used_assessor,
sampling_used_assessor,
sampling_rational,
sampling_standardise_control,
sampling_control_validation,
third_party_assessor_padss,
third_party_assessor_p2pe,
third_party_scope_reduction,
third_party_comments,
sp_is_sp,
sp_included_requirements,
sp_excluded_requirements,
sp_assessor,
sp_ip_addr,
sp_customer_ip_addr,
qs_initial,
qs_amount,
qs_pass_assessor,
qs_document_assessor,
qs_correction,
qs_assessor_comments,
qs_aoc_assessor
)
VALUES (
InProjectID,
InTimeframe,
InDateSpent,
InDateSpentDesc,
InQaName,
InWhyStoreDesc,
InChannelTypeDesc,
InOtherEntitiesDesc,
InNetworkDiagramDesc,
InScopingMethods,
InScopingConfirmationMethods,
InScopingMethodEvaluation,
InScopingMethodDocumentation,
InScopingMethodAccuracy,
InScopingAssessorName,
InEnvironmentPeople,
InEnvironmentProcesses,
InEnvironmentTechnologies,
InEnvironmentLocations,
InEnvironmentOther,
InSegmentationUsed,
InNoSegmentationAssessor,
InSegmentationHow,
InSegmentationTechnologies,
InSegmentationValidate,
InSegmentationFunction,
InSegmentationIntegrity,
InWithSegmentationAssessor,
InCountriesEntityConductsBusiness,
InWirelessVerify,
InWirelessImpact,
InSamplingNotUsedAssessor,
InSamplingUsedAssessor,
InSamplingRational,
InSamplingStandardiseControl,
InSamplingControlValidation,
InThirdPartyAssessorPadss,
InThirdPartyAssessorP2pe,
InThirdPartyScopeReduction,
InThirdPartyComments,
InSpIsSp,
InSpIncludedRequirements,
InSpExcludedRequirements,
InSpAssessor,
InSpIpAddr,
InSpCustomerIpAddr,
InQsInitial,
InQsAmount,
InQsPassAssessor,
InQsDocumentAssessor,
InQsCorrection,
InQsAssessorComments,
InQsAocAssessor
);
ELSE
UPDATE SummaryInfo SET
timeframe = InTimeframe,
date_spent = InDateSpent,
date_spent_desc = InDateSpentDesc,
qa_name = InQaName,
why_store_desc = InWhyStoreDesc,
channel_type_desc = InChannelTypeDesc,
other_entities_desc = InOtherEntitiesDesc,
network_diagram_desc = InNetworkDiagramDesc,
scoping_methods = InScopingMethods,
scoping_confirmation_methods = InScopingConfirmationMethods,
scoping_method_evaluation = InScopingMethodEvaluation,
scoping_method_documentation = InScopingMethodDocumentation,
scoping_method_accuracy = InScopingMethodAccuracy,
scoping_assessor_name = InScopingAssessorName,
environment_people = InEnvironmentPeople,
environment_processes = InEnvironmentProcesses,
environment_technologies = InEnvironmentTechnologies,
environment_locations = InEnvironmentLocations,
environment_other = InEnvironmentOther,
segmentation_used = InSegmentationUsed,
no_segmentation_assessor = InNoSegmentationAssessor,
segmentation_how = InSegmentationHow,
segmentation_technologies = InSegmentationTechnologies,
segmentation_validate = InSegmentationValidate,
segmentation_function = InSegmentationFunction,
segmentation_integrity = InSegmentationIntegrity,
with_segmentation_assessor = InWithSegmentationAssessor,
countries_entity_conducts_business = InCountriesEntityConductsBusiness,
wireless_verify = InWirelessVerify,
wireless_impact = InWirelessImpact,
sampling_not_used_assessor = InSamplingNotUsedAssessor,
sampling_used_assessor = InSamplingUsedAssessor,
sampling_rational = InSamplingRational,
sampling_standardise_control = InSamplingStandardiseControl,
sampling_control_validation = InSamplingControlValidation,
third_party_assessor_padss = InThirdPartyAssessorPadss,
third_party_assessor_p2pe = InThirdPartyAssessorP2pe,
third_party_scope_reduction = InThirdPartyScopeReduction,
third_party_comments = InThirdPartyComments,
sp_is_sp = InSpIsSp,
sp_included_requirements = InSpIncludedRequirements,
sp_excluded_requirements = InSpExcludedRequirements,
sp_assessor = InSpAssessor,
sp_ip_addr = InSpIpAddr,
sp_customer_ip_addr = InSpCustomerIpAddr,
qs_initial = InQsInitial,
qs_amount = InQsAmount,
qs_pass_assessor = InQsPassAssessor,
qs_document_assessor = InQsDocumentAssessor,
qs_correction = InQsCorrection,
qs_assessor_comments = InQsAssessorComments,
qs_aoc_assessor = InQsAocAssessor
WHERE
ProjectID = InProjectID;
END IF;
END//
DELIMITER ;
错误信息:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN InNoSegmentationAssessor INT,IN InSegmentationH' at line 22
当我像结构更改之前一样将 ENUM 改回 INT 时,存储过程加载时没有错误。但是它当然不会工作,因为它与数据库的结构不匹配。
我一直在寻找答案,但我清楚地知道在这个特定情况下我首先做错了什么。任何提示或建议都会很好。
是的,这是一个庞大的过程。它是遗留代码。是的,它是一个枚举。就是出报告。
声明 ENUM
时,您必须指定值。所以应该是:
IN InSegmentationUsed ENUM('Yes', 'No'),