我必须做一个查询才能得到一个参数(我需要一个“1”),但是这个参数可以在不同的单元格中,例如:
+--------------+--------------+--------------+
|....cell1.....|.....cell2....|....cell3.....|
+--------------+--------------+--------------+
|....here......|.....here.....|....or here...|
+--------------+--------------+--------------+
我必须捕获,然后,如果它等于一个,则执行其他查询以获得我想要的。我尝试用这段代码做一个程序:
SET TERM !! ;
CREATE PROCEDURE GET_CASH(
TICKET VARCHAR(15))
RETURNS ( TOTAL integer
)
AS
BEGIN
FOR SELECT a.ID_FPAY1, a.FPAY1_IMPORT, a.ID_FPAY2, a.FPAY2_IMPORT, a.ID_FPAY3, a.FPAY3_IMPORT
FROM TB_TICKETS_HIS a WHERE a.ID_TICKET = TICKET
DO
BEGIN
IF a.ID_FPAY1 = 1 THEN TOTAL = a.FPAY1_IMPORT;
IF a.ID_FPAY2 = 1 THEN TOTAL = a.FPAY2_IMPORT;
IF a.ID_FPAY3 = 1 THEN TOTAL = a.FPAY3_IMPORT;
SUSPEND;
END
END!!
SET TERM ; !!
执行查询时出现此错误:
SQL Message : -104
Invalid token
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 11, column 5
DO
我尝试删除 FOR 和 Do 的工作,出现此错误:
SQL Message : -104
Invalid token
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 11, column 5
BEGIN
有人可以帮助我完成此程序或向我解释失败的原因吗?