关于interbase存储过程的问题 ( 积分: 100 )

  • 主题发起人 主题发起人 smallfox
  • 开始时间 开始时间
S

smallfox

Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个存储过程如下<br>CREATE&nbsp;PROCEDURE&nbsp;TC_TOTAL&nbsp;(<br>&nbsp;&nbsp;end_date&nbsp;date,<br>&nbsp;&nbsp;begin_date&nbsp;date)<br>as<br>declare&nbsp;variable&nbsp;gh&nbsp;varchar(10);<br>declare&nbsp;variable&nbsp;name&nbsp;varchar(20);<br>declare&nbsp;variable&nbsp;xm_name&nbsp;varchar(30);<br>declare&nbsp;variable&nbsp;js&nbsp;integer;<br>declare&nbsp;variable&nbsp;jzjs&nbsp;integer;<br>declare&nbsp;variable&nbsp;tchj&nbsp;float;<br>begin<br>&nbsp;delete&nbsp;from&nbsp;bb_tc;<br>&nbsp;for&nbsp;select&nbsp;&quot;工号&quot;&nbsp;from&nbsp;yg_info&nbsp;into&nbsp;:gh&nbsp;do<br>&nbsp;begin<br>&nbsp;&nbsp;select&nbsp;&quot;姓名&quot;&nbsp;from&nbsp;yg_info&nbsp;where&nbsp;&quot;工号&quot;=:gh&nbsp;into&nbsp;:name;<br>&nbsp;&nbsp;for&nbsp;select&nbsp;&quot;项目名称&quot;&nbsp;from&nbsp;val_fwxm&nbsp;into&nbsp;:xm_name&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;select&nbsp;sum(&quot;节数&quot;),sum(&quot;加钟节数&quot;),sum(&quot;提成合计&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;YW_TC&nbsp;where<br>&nbsp;&nbsp;&nbsp;&nbsp;(&quot;本班日期&quot;&nbsp;between&nbsp;:begin_date&nbsp;and&nbsp;:end_date)<br>&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;&quot;项目名称&quot;=:xm_name&nbsp;into&nbsp;:js,&nbsp;:jzjs,&nbsp;:tchj;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;insert&nbsp;into&nbsp;bb_tc&nbsp;(&quot;开始日期&quot;,&quot;结束日期&quot;,&quot;工号&quot;,&quot;姓名&quot;,&quot;项目名称&quot;,&quot;节数&quot;,&quot;提成金额&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;values(:begin_date,:end_date,:gh,:name,:xm_name,:js+:jzjs,&nbsp;:tchj);<br><br>&nbsp;&nbsp;end<br>&nbsp;end<br>end^<br><br>现在我要在delphi中调用它提示出错<br><br>&nbsp;SqlStr:='execute&nbsp;procedure&nbsp;tc_total('+''''<br>&nbsp;+FormatDateTime('yyyy&quot;-&quot;mm&quot;-&quot;dd',RzDTPBeginDate.Date)+'&nbsp;00:00:00'+''''<br>&nbsp;+','+''''+FormatDateTime('yyyy&quot;-&quot;mm&quot;-&quot;dd',RzDTPEndDate.Date)+'&nbsp;23:59:59'+''''<br>&nbsp;+')';<br>&nbsp;ShowMessage(SqlStr);<br>&nbsp;FormDM.cdsTemp.Close;<br>&nbsp;FormDM.cdsTemp.CommandText:=SqlStr;<br>&nbsp;FormDM.cdsTemp.Execute;<br>请问该怎么处理?<br>我如果直接在IbConsol中执行<br>execute&nbsp;procedure&nbsp;tc_total('2007-1-1','2007-12-31')<br>计算出来全部为空值
 
传递参数有问题吧,不是字符串型而是日期型
 
把&nbsp;between&nbsp;:begin_date&nbsp;and&nbsp;:end_date&nbsp;改成<br>between&nbsp;cast(:begin_date&nbsp;as&nbsp;date)&nbsp;and&nbsp;cast(:end_date&nbsp;as&nbsp;date)<br>试试看。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
937
SUNSTONE的Delphi笔记
S
后退
顶部