View previous topic :: View next topic
|
Author |
Message |
rahul_kk
New User
Joined: 24 Nov 2006 Posts: 5 Location: Chennai
|
|
|
|
Hi,
In my COBOL program, I have a MAX(<Date>) query on a table. But, It fails to fetch the record with WHERE conditions.
Ex:
SELECT MAX(RUN_DATE)
FROM STMT_CNTL
WHERE <Conditions>
Above query fails even with a valid record exists in the table. When I execute this query separately in SPUFI/QMF it fetches the record.
Also, simple SELECT statement on the same table failed.
Ex:
SELECT RLSE_DATE
INTO :<Host-variable>
FROM STMT_CNTL
WHERE <Conditions>
A record exists for this conditions in the table. These queries are failing when I execute thru COBOL program.
What could be the reason for this? Is there any problem with DB2 table like RUNSTATS/REORG/Tablespace/Indexes etc???
Thanks,
Rahul |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
If You want some help You need to post some meaningful info
"the query fails" is a bit generic to start any problem determination
what about looking at the sqlcode and search it in the manuals
it should give You a good hint to start fixing the problem |
|
Back to top |
|
|
rahul_kk
New User
Joined: 24 Nov 2006 Posts: 5 Location: Chennai
|
|
|
|
Hi,
SELECT MAX(RUN_DATE)
INTO :<Host-variable>
FROM STMT_CNTL
WHERE <Conditions>
Above query gives SQLCODE as 0 with blank value in Host-variable. It fetches the record when executes in SPUFI/QMF.
SELECT RLSE_DATE
INTO :<Host-variable>
FROM STMT_CNTL
WHERE <Conditions>
Above query gives SQLCODE as 100. It fetches the record when executes in SPUFI/QMF.
Thanks,
Rahul |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
either your secret WHERE conditions have something wrong or your from table is not the table that you think. |
|
Back to top |
|
|
rahul_kk
New User
Joined: 24 Nov 2006 Posts: 5 Location: Chennai
|
|
|
|
Hi,
I displayed the values passed in WHERE conditions before and after the query. With same values the query executed separately in SPUFI/QMF. If "from table" is not a table, then it should give some other error instead of giving SQLCODE = 100. Same query with same table name and conditions, executed in SPUFI/QMF.
Rahul |
|
Back to top |
|
|
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai
|
|
|
|
You have not produce your "Where Clause" instead you are repeating the same [/quote] |
|
Back to top |
|
|
sainathvinod
New User
Joined: 01 Apr 2008 Posts: 11 Location: Chennai
|
|
|
|
Please verify that the DB2 region in which the query was executed independently and the DB2 region in which the program was compiled is one and the same. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Please also list some selected rows without the WHERE clause so we can see that there are in fact matching rows. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Do you have a null indicator field for the host-variable and are you checking it? |
|
Back to top |
|
|
SSR Warnings : 1 New User
Joined: 26 Feb 2006 Posts: 38
|
|
|
|
Hi,
Check if you have run the query and bound the plan to the same region and qualifier.
Regards
Sundar |
|
Back to top |
|
|
|