Hello,
We are experiencing a strange problem with our application. We have a C++ application that opens a DB2 cursor using an embedded SQL statement (so the SQL is a static one). All select criteria values are hard coded (no host variables are being used). The number of records selected by the cursor is 3068. If we run the exact same select statement from the command line (so it is dynamic one now) using the exact same select criteria we have 3498 records selected. We cannot understand the difference of 430 records between the 2 select statements. We tried this test on 3 different environments (i.e. servers) with the same database image an the problem is consistent. We use DB2 V8 on AIX. First 2 tests were done on an environment with Fix Pack 10 the last one on an environment with Fix pack 13. The select statement is not complex as you can see below:
Cursor, i.e. static select statement:
EXEC SQL DECLARE c151 CURSOR WITH HOLD FOR
SELECT ....
FROM tableA t,
tableB m
WHERE EXISTS
(SELECT 1
FROM tableC
pr,
tableD pl,
tableE dp,
tableF sp
WHERE
pr.extract_id = '2007-05-30-16.16.41.265070'
AND
pr.plan_coid = sp.account_coid
AND
pr.plan_sp_id = sp.product_seq
AND dp.product_coid = sp.defining_prod_coid
AND pl.product_id = dp.product_id
AND pl.plan_holdings_type = 119210368
AND
pr.plan_coid = t.account_coid)
AND m.Source_ = 125569856
AND t.txn_type = m.Txn_type
AND t.Post_Date >= x'002573C3000000000804011B'
AND t.Post_Date >= x'00256D20000000000804011B'
AND t.Post_Date <= x'0025741D0001517F0804011B'
AND NOT EXISTS
(SELECT 1
FROM tableG st
WHERE extract_id = '2007-05-30-16.16.41.385273'
AND st.plan_coid = t.account_coid
AND st.plan_sp_id = t.product_id
AND st.request_id = 0)
ORDER BY t.Account_Coid,
t.Effective_Date,
t.Top_Level_Txn_Id,
t.Reversal_,
t.Txn_Id
FOR READ ONLY;
Command line one, i.e. dynamic select statement:
SELECT ...
FROM tableA t,
tableB m
WHERE EXISTS
(SELECT 1
FROM tableC
pr,
tableD pl,
tableE dp,
tableF sp
WHERE
pr.extract_id = '2007-05-30-16.16.41.265070'
AND
pr.plan_coid = sp.account_coid
AND
pr.plan_sp_id = sp.product_seq
AND dp.product_coid = sp.defining_prod_coid
AND pl.product_id = dp.product_id
AND pl.plan_holdings_type = 119210368
AND
pr.plan_coid = t.account_coid)
AND m.Source_ = 125569856
AND t.txn_type = m.Txn_type
AND t.Post_Date >= x'002573C3000000000804011B'
AND t.Post_Date >= x'00256D20000000000804011B'
AND t.Post_Date <= x'0025741D0001517F0804011B'
AND NOT EXISTS
(SELECT 1
FROM tableG st
WHERE extract_id = '2007-05-30-16.16.41.385273'
AND st.plan_coid = t.account_coid
AND st.plan_sp_id = t.product_id
AND st.request_id = 0)
ORDER BY t.Account_Coid,
t.Effective_Date,
t.Top_Level_Txn_Id,
t.Reversal_,
t.Txn_Id
Any suggestions would be more than welcome.
Thanks, Ioan.