IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SELECCT, MAX() queries not working on a DB2 table. Reason???


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rahul_kk

New User


Joined: 24 Nov 2006
Posts: 5
Location: Chennai

PostPosted: Tue Jun 17, 2008 11:54 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 17, 2008 12:37 pm
Reply with quote

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
View user's profile Send private message
rahul_kk

New User


Joined: 24 Nov 2006
Posts: 5
Location: Chennai

PostPosted: Tue Jun 17, 2008 1:09 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 17, 2008 1:56 pm
Reply with quote

either your secret WHERE conditions have something wrong or your from table is not the table that you think.
Back to top
View user's profile Send private message
rahul_kk

New User


Joined: 24 Nov 2006
Posts: 5
Location: Chennai

PostPosted: Tue Jun 17, 2008 2:06 pm
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Tue Jun 17, 2008 3:16 pm
Reply with quote

You have not produce your "Where Clause" instead you are repeating the same [/quote]
Back to top
View user's profile Send private message
sainathvinod

New User


Joined: 01 Apr 2008
Posts: 11
Location: Chennai

PostPosted: Tue Jun 17, 2008 5:01 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Jun 17, 2008 5:55 pm
Reply with quote

Please also list some selected rows without the WHERE clause so we can see that there are in fact matching rows.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 17, 2008 5:59 pm
Reply with quote

Do you have a null indicator field for the host-variable and are you checking it?
Back to top
View user's profile Send private message
SSR
Warnings : 1

New User


Joined: 26 Feb 2006
Posts: 38

PostPosted: Wed Jun 18, 2008 1:38 pm
Reply with quote

Hi,

Check if you have run the query and bound the plan to the same region and qualifier.

Regards
Sundar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Reorg abended with REASON=X'00E40347' DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top