Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: SELECCT, MAX() queries not working on a DB2 table. Reason???
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Tue Jun 17, 2008 12:37 pm    Post subject: Reply to: SELECCT, MAX() queries not working on a DB2 table.
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Active Member


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

PostPosted: Tue Jun 17, 2008 5:55 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: SELECCT, MAX() queries not working on a DB2 table.
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts SCRNAME not working on my mainframe? mrsidhu12 TSO/ISPF 7 Thu Sep 01, 2016 2:17 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us