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
 

 

DB2 error or what

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Thu Apr 24, 2008 1:16 am    Post subject: DB2 error or what
Reply with quote

Hi All,

Please check the below spufis:

1
Code:

  SELECT * FROM TB019                                       
     WHERE  JSPN = '6775607' AND   START_DATE >= '03.04.2008' 
      AND   END_DATE <= '03.04.2008';                                 
---------+---------+---------+---------+---------+---------+---------+-
JS_PROD_CODE  BR_CODE  EFDTE       ADJ_ON_SALE_DATE  ORIG_ON_SALE_DATE
---------+---------+---------+---------+---------+---------+---------+-
DSNE610I NUMBER OF ROWS DISPLAYED IS 0                                 
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100           
---------+---------+---------+---------+---------+---------+---------+-


2
Code:
SELECT ADJ_ON_SALE_DATE FROM TB019                         
     WHERE  JSPN = '6775607' AND   START_DATE >= '03.04.2008' 
      AND   END_DATE <= '03.04.2008';                                 
---------+---------+---------+---------+---------+---------+---------+-
ADJ_ON_SALE_DATE                                                       
---------+---------+---------+---------+---------+---------+---------+-
DSNE610I NUMBER OF ROWS DISPLAYED IS 0                                 
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100   


3
Code:
SELECT MIN(ADJ_ON_SALE_DATE) AS IDATE FROM TB019         
     WHERE  JSPN = '6775607' AND   START_DATE >= '03.04.2008'
      AND   END_DATE <= '03.04.2008';                                 
---------+---------+---------+---------+---------+---------+---------+
IDATE                                                                 
---------+---------+---------+---------+---------+---------+---------+
----------                                                           
DSNE610I NUMBER OF ROWS DISPLAYED IS 1                               
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100   


4
Code:
SELECT MIN(ADJ_ON_SALE_DATE)  FROM TB019         
     WHERE  JSPN = '6775607' AND   START_DATE >= '03.04.2008'
      AND   END_DATE <= '03.04.2008';                                 
---------+---------+---------+---------+---------+---------+---------+

---------+---------+---------+---------+---------+---------+---------+
----------                                                           
DSNE610I NUMBER OF ROWS DISPLAYED IS 1                               
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100   


All the Spufis are same just having difference in the select, but the output is different.

The third and fourth spufi is giving some garbage value as hyphen, which causing some problem for a job.
Can anybody help why its giving different result, is it some error which can be corrected or a DB2 bug.

Thanks,
Nirmal
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


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

PostPosted: Thu Apr 24, 2008 1:26 am    Post subject:
Reply with quote

Quote:
DB2 error or what????


No just a user error!

The --------- is how SPUFI displays a null column.

In the first 2 you are getting the headings for the columns but since no rows satisfied your where there is not data under the headings.
In number 3 you got the column heading and the ----------- under that is a null value that was returned since no rows satisfied your where.
In number 4 you didn't get the column heading because you didn't specify what name to use for MIN(ADJ_ON_SALE_DATE) and the ----------- under that is a null value that was returned since no rows satisfied your where.
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Thu Apr 24, 2008 1:30 am    Post subject:
Reply with quote

Hi Craq,

Do you mean whenever i will do a select on a single column and there will be no data to fetch it will give some null value as the output?

Thanks,
Nirmal
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Thu Apr 24, 2008 2:02 am    Post subject:
Reply with quote

When you use a column function that can return null as in number 3 & 4, yes. In number 1 & 2 you didn't get any data, look closely at the output from the samples you posted.

----+----+----+ separator before the headings
column headings
----+----+----+ separator before the data
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu Apr 24, 2008 12:03 pm    Post subject:
Reply with quote

when we are selecting a row from the table and no row matches the WHERE clause then we get 0 rows selected.

and in case of column function, if the WHERE clause is not satisfied with any rows then we get a NULL as the output.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Apr 24, 2008 5:46 pm    Post subject:
Reply with quote

So basically you need to add a null indicator variable to your program and on specify what it is on your select. Check that variable before further processing the record.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm
No new posts INVOKE WEBSERVICE error danik56 CICS 11 Thu Mar 09, 2017 11:52 am
No new posts Row not found Sql error GaganGarg DB2 7 Tue Mar 07, 2017 6:29 am
No new posts DB2 SQL Error: SQLCODE=-440, SQLSTATE... kishpra DB2 1 Sat Feb 18, 2017 2:31 am


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