我在MySQL中有这个存储过程。但是它显示错误并且没有指定错误到底是什么。
我的存储过程如下:
CREATE DEFINER=`root`@`localhost` PROCEDURE 'spmselfinformation'
(
Sid int,
SCompany_Name varchar(45),
SAddress1 varchar(100),
SAddress2 varchar(100),
SCity varchar(45),
SPincode int,
SContact_Person varchar(45),
STelephone int,
STelefax int,
SEmail_Address varchar(45),
SReport_Signature varchar(100),
SState_Sale_Taxno varchar(45),
SCentral_Taxno varchar(45),
SLic1 varchar(45),
SDate1 as Datetime,
SLic2 varchar(45),
SDate2 as Datetime,
SDate_Of_Entry as Datetime,
SLic3 varchar(45),
SDate3 as Datetime,
STTIN_No varchar(45),
SVATTIN_No varchar(45),
SLBT_No varchar(45),
STerms_and_Conditions1 varchar(100),
STerms_and_Conditions2 varchar(100),
STerms_and_Conditions3 varchar(100),
STerms_and_Conditions4 varchar(100),
SLogo_File_Name varchar(45),
SWebsite varchar(100),
SOpen_Hours varchar(45),
SNote varchar(100),
SFlag int
)
BEGIN
if SFlag=1 then
INSERT INTO tbl_selfinformation (id,Company_Name,Address1,Address2,City,Pincode,Contact_Person,Telephone,Telefax,Email_Address,Report_Signature,State_Sale_Taxno,Central_Taxno,Lic1,Date1,Lic2,Date2,Date_Of_Entry,Lic3,Date3,TTIN_No,VATTIN_No,LBT_No,Terms_and_Conditions1,Terms_and_Conditions2,Terms_and_Conditions3,Terms_and_Conditions4,Logo_File_Name,Website,Open_Hours,Note) VALUES(Sid,SCompany_Name,SAddress1,SAddress2,SCity,SPincode,SContact_Person,STelephone,STelefax,SEmail_Address,SReport_Signature,SState_Sale_Taxno,SCentral_Taxno,SLic1,SDate1,SLic2,SDate2,SDate_Of_Entry,SLic3,SDate3,STTIN_No,SVATTIN_No,SLBT_No,STerms_and_Conditions1,STerms_and_Conditions2,STerms_and_Conditions3,STerms_and_Conditions4,SLogo_File_Name,SWebsite,SOpen_Hours,SNote);
END if;
IF SFlag =2 then
UPDATE tbl_selfinformation SET id=Sid,Company_Name=SCompany_Name,Address1=SAddress1,Address2=SAddress2,City=SCity,Pincode=SPincode,Contact_Person=SContact_Person,Telephone=STelephone,Telefax=STelefax,Email_Address=SEmail_Address,Report_Signature=SReport_Signature,State_Sale_Taxno=SState_Sale_Taxno,Central_Taxno=SCentral_Taxno,Lic1=SLic1,Date1=SDate1,Lic2=SLic2,Date2=SDate2,Date_Of_Entry=SDate_Of_Entry,Lic3=SLic3,Date3=SDate3,TTIN_No=STTIN_No,VATTIN_No=SVATTIN_No,LBT_No=SLBT_No,Terms_and_Conditions1=STerms_and_Conditions1,Terms_and_Conditions2=STerms_and_Conditions2,Terms_and_Conditions3=STerms_and_Conditions3,Terms_and_Conditions4=STerms_and_Conditions4,Logo_File_Name=SLogo_File_Name,Website=SWebsite,Open_Hours=SOpen_Hours,Note=SNote;
END if;
END
显示此屏幕。
我无法弄明白我究竟做错了什么。任何人都可以帮助我。
编辑1
这是我的表定义
DROP TABLE IF EXISTS `invntory_system`.`tbl_selfinformation`;
CREATE TABLE `invntory_system`.`tbl_selfinformation` (
`id` int(10) unsigned NOT NULL default '0',
`Company_Name` varchar(45) NOT NULL default '',
`Address1` varchar(100) NOT NULL default '',
`Address2` varchar(100) default NULL,
`City` varchar(45) NOT NULL default '',
`Pincode` int(10) unsigned NOT NULL default '0',
`Contact_Person` varchar(45) NOT NULL default '',
`Telephone` int(10) unsigned NOT NULL default '0',
`Telefax` int(10) unsigned default NULL,
`Email_Address` varchar(45) NOT NULL default '',
`Report_Signature` varchar(100) NOT NULL default '',
`State_Sale_Taxno` varchar(45) NOT NULL default '',
`Central_Taxno` varchar(45) NOT NULL default '',
`Lic1` varchar(45) default NULL,
`Date1` datetime default NULL,
`Lic2` varchar(45) default NULL,
`Date2` datetime default NULL,
`Date_Of_Entry` datetime NOT NULL default '0000-00-00 00:00:00',
`Lic3` varchar(45) default NULL,
`Date3` datetime default NULL,
`TTIN_No` varchar(45) NOT NULL default '',
`VATTIN_No` varchar(45) NOT NULL default '',
`LBT_No` varchar(45) NOT NULL default '',
`Terms_and_Conditions1` varchar(100) default NULL,
`Terms_and_Conditions2` varchar(100) default NULL,
`Terms_and_Conditions3` varchar(100) default NULL,
`Terms_and_Conditions4` varchar(100) default NULL,
`Logo_File_Name` varchar(45) default NULL,
`Website` varchar(100) default NULL,
`Open_Hours` varchar(45) default NULL,
`Note` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Self Information';
答案 0 :(得分:2)
代码中存在一些问题:程序的名称不应该用单引号括起来。日期时间变量应该声明为datetime
而不是as datetime
,最后我认为您需要从分号更改分隔符,以便"修复"应该工作的脚本如下所示:
DELIMITER //
CREATE DEFINER=`root`@`localhost` PROCEDURE spmselfinformation
(
Sid int,
SCompany_Name varchar(45),
SAddress1 varchar(100),
SAddress2 varchar(100),
SCity varchar(45),
SPincode int,
SContact_Person varchar(45),
STelephone int,
STelefax int,
SEmail_Address varchar(45),
SReport_Signature varchar(100),
SState_Sale_Taxno varchar(45),
SCentral_Taxno varchar(45),
SLic1 varchar(45),
SDate1 Datetime,
SLic2 varchar(45),
SDate2 Datetime,
SDate_Of_Entry Datetime,
SLic3 varchar(45),
SDate3 Datetime,
STTIN_No varchar(45),
SVATTIN_No varchar(45),
SLBT_No varchar(45),
STerms_and_Conditions1 varchar(100),
STerms_and_Conditions2 varchar(100),
STerms_and_Conditions3 varchar(100),
STerms_and_Conditions4 varchar(100),
SLogo_File_Name varchar(45),
SWebsite varchar(100),
SOpen_Hours varchar(45),
SNote varchar(100),
SFlag int
)
BEGIN
IF SFlag = 1 THEN
INSERT INTO tbl_selfinformation (id,Company_Name,Address1,Address2,City,Pincode,Contact_Person,Telephone,Telefax,Email_Address,Report_Signature,State_Sale_Taxno,Central_Taxno,Lic1,Date1,Lic2,Date2,Date_Of_Entry,Lic3,Date3,TTIN_No,VATTIN_No,LBT_No,Terms_and_Conditions1,Terms_and_Conditions2,Terms_and_Conditions3,Terms_and_Conditions4,Logo_File_Name,Website,Open_Hours,Note) VALUES(Sid,SCompany_Name,SAddress1,SAddress2,SCity,SPincode,SContact_Person,STelephone,STelefax,SEmail_Address,SReport_Signature,SState_Sale_Taxno,SCentral_Taxno,SLic1,SDate1,SLic2,SDate2,SDate_Of_Entry,SLic3,SDate3,STTIN_No,SVATTIN_No,SLBT_No,STerms_and_Conditions1,STerms_and_Conditions2,STerms_and_Conditions3,STerms_and_Conditions4,SLogo_File_Name,SWebsite,SOpen_Hours,SNote);
END IF;
IF SFlag = 2 THEN
UPDATE tbl_selfinformation SET id=Sid,Company_Name=SCompany_Name,Address1=SAddress1,Address2=SAddress2,City=SCity,Pincode=SPincode,Contact_Person=SContact_Person,Telephone=STelephone,Telefax=STelefax,Email_Address=SEmail_Address,Report_Signature=SReport_Signature,State_Sale_Taxno=SState_Sale_Taxno,Central_Taxno=SCentral_Taxno,Lic1=SLic1,Date1=SDate1,Lic2=SLic2,Date2=SDate2,Date_Of_Entry=SDate_Of_Entry,Lic3=SLic3,Date3=SDate3,TTIN_No=STTIN_No,VATTIN_No=SVATTIN_No,LBT_No=SLBT_No,Terms_and_Conditions1=STerms_and_Conditions1,Terms_and_Conditions2=STerms_and_Conditions2,Terms_and_Conditions3=STerms_and_Conditions3,Terms_and_Conditions4=STerms_and_Conditions4,Logo_File_Name=SLogo_File_Name,Website=SWebsite,Open_Hours=SOpen_Hours,Note=SNote;
END IF;
END //
DELIMITER ;