一段建立存诸过程的sql语句在查询分析器中执行一切正常 。放在adoquery中,adoquery.exec就说在关键字procedure附近有语法错误? (

  • 主题发起人 主题发起人 llz629
  • 开始时间 开始时间
L

llz629

Unregistered / Unconfirmed
GUEST, unregistred user!
一段建立存诸过程的sql语句在查询分析器中执行一切正常 。放在adoquery中,adoquery.exec就说在关键字procedure附近有语法错误? ( 积分: 50 )<br />一段建立存诸过程的sql语句在查询分析器中执行一切正常&nbsp;&nbsp;。放在adoquery中,adoquery.exec就说在关键字procedure附近有语法错误?
 
要看一看代码才知
 
CREATE&nbsp;PROCEDURE&nbsp;cgfpjz(&nbsp;@adate&nbsp;datetime,&nbsp;@idigest&nbsp;varchar(15),&nbsp;@vid&nbsp;varchar(25),@code&nbsp;varchar(25),&nbsp;@isymoney&nbsp;money,&nbsp;@cmaker&nbsp;varchar(10),&nbsp;@cpersonname&nbsp;varchar(25),@cvenname&nbsp;varchar(25)&nbsp;&nbsp;&nbsp;)&nbsp;AS<br>&nbsp;<br>&nbsp;Insert&nbsp;into&nbsp;cgclosebill&nbsp;(ddate,idigest,&nbsp;vid,code,imoney,cmaker,cpersonname,cvenname,cvouchtype,isauto)&nbsp;&nbsp;<br>&nbsp;values&nbsp;(&nbsp;@adate,@idigest,@vid,@code,&nbsp;@isymoney&nbsp;,@cmaker&nbsp;,@cpersonname,@cvenname,'4','1'&nbsp;)
 
经过测试发现:如果是一个简单的存诸过程是可以正确执行的。<br>但是如果是一个复杂的,执行时报错:什么参数不正确。<br>难道就没有人以前碰到这种情况吗?
 
把源代码贴上来呀!
 
Create&nbsp;Procedure&nbsp;jz(@f&nbsp;varchar(2),@Code&nbsp;varchar(20),@adate&nbsp;datetime,@amonth&nbsp;varchar(2))<br>As<br>Insert&nbsp;into&nbsp;IA_subsidiary&nbsp;Select&nbsp;@f,rdrecord.Code,@adate,&nbsp;@amonth&nbsp;,rdrecords.cwhname,rdrecords.cinvcode,rdrecords.iquantity,rdrecords.icost,<br>rdrecords.imoney,&nbsp;rdrecord.caccounter,&nbsp;rdrecord.cvouchtype&nbsp;&nbsp;From&nbsp;rdrecord&nbsp;Inner&nbsp;Join&nbsp;rdrecords&nbsp;On&nbsp;rdrecord.Vid=rdrecords.Vid&nbsp;where&nbsp;rdrecord.code&nbsp;=&nbsp;@code<br>就可以
 
if&nbsp;object_id('dbo.crksum')&nbsp;is&nbsp;not&nbsp;null&nbsp;drop&nbsp;Procedure&nbsp;crksum<br>go<br>CREATE&nbsp;PROCEDURE&nbsp;crksum(@start_date&nbsp;varchar(10),@end_date&nbsp;varchar(10),@cinvcode&nbsp;varchar(60),@style&nbsp;varchar(2)&nbsp;,@cwhname&nbsp;varchar(16),@sl&nbsp;float&nbsp;&nbsp;output&nbsp;)&nbsp;AS<br>&nbsp;<br><br>if&nbsp;@style='1'&nbsp;&nbsp;<br>begin<br>begin<br>if&nbsp;@cwhname&nbsp;=''&nbsp;<br>&nbsp;begin<br>&nbsp;&nbsp;&nbsp;select&nbsp;@sl=&nbsp;sum(iquantity)&nbsp;&nbsp;<br>from&nbsp;ia_subsidiary<br>where&nbsp;&nbsp;ddate&gt;=@start_date&nbsp;and&nbsp;&nbsp;ddate&lt;=@end_date&nbsp;and&nbsp;&nbsp;cinvcode=@cinvcode&nbsp;<br>and&nbsp;&nbsp;brdflag&nbsp;='1'<br>end<br>&nbsp;else<br>if&nbsp;@cwhname&nbsp;&lt;&gt;&nbsp;''&nbsp;<br>&nbsp;begin<br>&nbsp;&nbsp;&nbsp;select&nbsp;@sl=&nbsp;sum(iquantity)&nbsp;&nbsp;<br>from&nbsp;ia_subsidiary<br>where&nbsp;&nbsp;ddate&gt;=@start_date&nbsp;and&nbsp;&nbsp;ddate&lt;=@end_date&nbsp;and&nbsp;&nbsp;cinvcode=@cinvcode&nbsp;&nbsp;and&nbsp;cwhname=@cwhname<br>and&nbsp;&nbsp;brdflag&nbsp;='1'<br>end<br>end<br>end<br><br><br>if&nbsp;@style='0'&nbsp;&nbsp;<br>begin<br>begin<br>if&nbsp;@cwhname&nbsp;=''&nbsp;<br>&nbsp;begin<br>&nbsp;&nbsp;&nbsp;select&nbsp;@sl=&nbsp;sum(iquantity)&nbsp;&nbsp;<br>from&nbsp;ia_subsidiary<br>where&nbsp;&nbsp;ddate&gt;=@start_date&nbsp;and&nbsp;&nbsp;ddate&lt;=@end_date&nbsp;and&nbsp;&nbsp;cinvcode=@cinvcode&nbsp;<br>and&nbsp;&nbsp;brdflag&nbsp;='0'<br>end<br>&nbsp;else<br>if&nbsp;@cwhname&nbsp;&lt;&gt;&nbsp;''&nbsp;<br>&nbsp;begin<br>&nbsp;&nbsp;&nbsp;select&nbsp;@sl=&nbsp;sum(iquantity)&nbsp;&nbsp;<br>from&nbsp;ia_subsidiary<br>where&nbsp;&nbsp;ddate&gt;=@start_date&nbsp;and&nbsp;&nbsp;ddate&lt;=@end_date&nbsp;and&nbsp;&nbsp;cinvcode=@cinvcode&nbsp;&nbsp;and&nbsp;cwhname=@cwhname<br>and&nbsp;&nbsp;brdflag&nbsp;='0'<br>end<br>end<br>end<br>就不行了。<br>比如我要用delphi动态创建存储过程,有十几个。应怎么办呀?
 
参数设置不正确。
 
接受答案了.
 
后退
顶部