如何处理 sql server 2008 查询中的动态输入值。
我的情况是在下面的查询中,我有两个输入参数从 java 通过 i-batis 传递
1) if i enter stlmtTransId field alone query should execute (paymentTransId is empty now).
2) if i enter paymentTransId field alone query should execute(stlmtTransId is empty now).
3) if i enter both input values query should execute for matching the two inputs.
在任何上述情况下,我都需要输出。如何处理它。
SELECT
STLMT_TRANS.SETTLEMENT_TRANSACTION_ID
,STLMT_TRANS.PC_TRANSACTION_ID
,STLMT_TRANS.TRANSACTION_AMOUNT
,STLMT_TRANS.PAYMENT_AGENT_ID
,STLMT_TRANS.PAYMENT_AGENCY_ID
,STLMT_TRANS.PAYMENT_TRANS_DATE
FROM
T_SETTLEMENT_TRANSACTION STLMT_TRANS WITH (NOLOCK)
WHERE
STLMT_TRANS.SETTLEMENT_TRANSACTION_ID=#stlmtTransId#
AND
STLMT_TRANS.PC_TRANSACTION_ID=#paymentTransId#
注意:我使用 java + I-Batis