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

DB2 error or what


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top