错误-104创建Firebird存储过程的命令意外结束 [英] Error -104 Unexpected end of command creating a Firebird stored procedure

查看:189
本文介绍了错误-104创建Firebird存储过程的命令意外结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Firebird中创建一个存储过程:

I want to create a stored procedure in Firebird:

 CREATE PROCEDURE CalcPvIncome
 ( BeginDate date,
   EndDate   date,
   KwPrice   decimal (2,2) ) 
   
RETURNS ( Total_PV_Production decimal (9,2),
          Total_Income decimal (9,2) )
AS
BEGIN
  
   FOR SELECT SUM(ENERGY/1000), SUM((ENERGY/1000) * :KwPrice) 
       FROM PVPROD 
       WHERE proddate >= :BeginDate AND proddate <= :Enddate 
       INTO :Total_PV_Production , :Total_Income
       DO
       
       BEGIN
        SUSPEND ;
       END
END

我收到此错误:

引擎代码:335544569

Engine Code : 335544569

引擎消息:动态SQL错误SQL错误代码= -104意外结束的命令-第18行,第9列

Engine Message : Dynamic SQL Error SQL error code = -104 Unexpected end of command - line 18, column 9

SQL语句:

SELECT 
   SUM(ENERGY/1000) AS Total_PV_Production, 
   sum((ENERGY/1000)*0.55) as Total_Income
FROM 
   PVPROD 
where  
   proddate >= '12.06.2012' and  proddate <= '12.07.2012'

推荐答案

您必须在存储过程之前和之后添加SET TERM语句.用于更改终止符".这是一个示例:

You have to add SET TERM statement before and after the stored procedure. It is used to change the "terminator character". Here's an example:

SET TERM ^ ;

CREATE PROCEDURE CalcPvIncome
( BeginDate date,
  EndDate   date,
  KwPrice   decimal (2,2) ) 

RETURNS ( Total_PV_Production decimal (9,2),
          Total_Income decimal (9,2) )
AS
BEGIN
  ...
END

SET TERM ; ^

请注意,默认终止符为^,还请注意,您要在存储过程声明之前将;设置为新终止符,并将其重置为^.

Note that default terminator is ^ and also note that you are setting ; as new terminator before and resetting it back to ^ after stored procedure declaration.

这篇关于错误-104创建Firebird存储过程的命令意外结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆