开发者

How to reference the same parameter more than once in a Informix query?

I have a query which I am executing through ODBC on an Informix database. The query is being passed a Parameter (StartDate). I need to use the year of the StartDate numerous times get the data from the correct fields. When I use the query as listed below, it thinks there are 9 parameters. Therefore, I know this syntax is incorrect, however, I am unable to locate the correct syntax. So...

How do I reference the same parameter more than once in a Informix query?

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  开发者_JAVA百科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

Thanks in advance for any time and help you can offer.


You have to supply the parameter as many times as it is referenced; if there are 9 placeholders, you need to supply 9 values, and if it is the same value 9 times, so be it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜