我有一个查询,我在Informix数据库上通过ODBC执行。查询正在传递参数(StartDate)。我需要多次使用StartDate的年份从正确的字段中获取数据。当我使用下面列出的查询时,它认为有9个参数。因此,我知道这种语法不正确,但是,我无法找到正确的语法。所以......
如何在Informix查询中多次引用相同的参数?
SELECT glma_segx AS AccountNumber,
glma_obj As AccountObject,
glma_accttp AS AccountType,
glma_desc AS AccountName,
glma_seg1 AS AccountSeg1,
glma_seg2 AS AccountSeg2,
glma_seg3 AS AccountSeg3,
glma_seg4 AS AccountSeg4,
glma_seg5 AS AccountSeg5,
glma_seg6 AS AccountSeg6,
glma_seg7 AS AccountSeg7,
glma_seg8 AS AccountSeg8,
YEAR(?) AS BudgetYear,
CASE WHEN YEAR(?) = glma_bud_yr THEN glma_memo_bal_cy
WHEN YEAR(?) = glma_bud_yr - 1 THEN glma_memo_bal_ly1
WHEN YEAR(?) = glma_bud_yr + 1 THEN glma_memo_bal_ny
ELSE 0
END AS YTDActuals,
CASE WHEN YEAR(?) = glma_bud_yr THEN glma_encumb_cy
WHEN YEAR(?) = glma_bud_yr - 1 THEN glma_encumb_ly1
WHEN YEAR(?) = glma_bud_yr + 1 THEN glma_encumb_ny
ELSE 0
END AS YTDEncumbrances,
CASE WHEN YEAR(?) = glma_bud_yr THEN glma_req_cy
WHEN YEAR(?) = glma_bud_yr + 1 THEN glma_req_ny
ELSE 0
END AS YTDRequisitions
FROM GLMaster, glparams
WHERE glma_seg1 NOT LIKE 'H%'
AND glmaster.glma_bud_yr=glparams.glpa_curr_yr
提前感谢您提供的任何时间和帮助。
答案 0 :(得分:0)
您必须提供参数的次数;如果有9个占位符,则需要提供9个值,如果它是9个相同的值,那就这样吧。