日期:2014-05-16  浏览次数:21336 次

如何用参数控制执行不同的sql语句(在线等答案)
做一个finereport报表,从页面传值到报表,页面可以选择部分客户,也可以选全部客户,URL传值时按照这两种情况传值,一种传客户codeID,一种不传客户codeID,报表的sql语句能否根据两种情况,分别执行不同的语句呢? 请大侠指教。
 sql:
  SELECT c.scode, c.sname, ttt.*
  FROM (SELECT tt.*
  FROM ( ( SELECT MAX (amount) AS maxAmount, NCLIENTID
  FROM ( SELECT b.NCLIENTID,
  SUM (A.MAMOUNT) AS amount,
  A.DTEXECUTE
  FROM SETT_TRANSACCOUNTDETAIL a,
  SETT_ACCOUNT b
  WHERE A.NTRANSACCOUNTID = B.ID
  AND A.NSTATUSID = 3
  AND A.NOFFICEID = 1
  AND A.NCURRENCYID = 1
  AND A.NTRANSACTIONTYPEID IN
  (1, 12, 15)
  AND A.NTRANSDIRECTION = 2
  AND A.DTEXECUTE BETWEEN TO_DATE (
  '2011-01-01',
  'yyyy-mm-dd'
  )
  AND TO_DATE (
  '2011-05-01',
  'yyyy-mm-dd'
  )
  GROUP BY b.NCLIENTID, A.DTEXECUTE
  ORDER BY b.NCLIENTID, A.DTEXECUTE)
  GROUP BY NCLIENTID) t
  JOIN
  ( SELECT b.NCLIENTID,
  SUM (A.MAMOUNT) AS amount,
  A.DTEXECUTE
  FROM SETT_TRANSACCOUNTDETAIL a, SETT_ACCOUNT b
  WHERE  
  A.NTRANSACCOUNTID = B.ID
  AND A.NSTATUSID = 3
  AND A.NOFFICEID = 1
  AND A.NCURRENCYID = 1
  AND A.NTRANSACTIONTYPEID IN (1, 12, 15)
  AND A.NTRANSDIRECTION = 2
  AND A.DTEXECUTE BETWEEN TO_DATE (
  '2011-01-01',
  'yyyy-mm-dd'
  )
  AND TO_DATE (
  '2011-05-01',
  'yyyy-mm-dd'
  )
  GROUP BY b.NCLIENTID, A.DTEXECUTE
  ORDER BY b.NCLIENTID, A.DTEXECUTE) tt
  ON t.maxAmount = tt.amount AND t.NCLIENTID = tt.NCLIENTID))
  ttt,
  client c
 WHERE t