MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

to show the manipulated values from SQL query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Mon Sep 17, 2007 1:28 pm    Post subject: to show the manipulated values from SQL query Reply with quote

I have a requirement like below:

After querying the database, I'll manipulate the values, and i would like to display the new values without using a programming language. It would be good if I can display using QMF or SPUFI.

here is an example:
SELECT AMOUNT,EMP_ID
FROM EMP;
IF AMOUNT > 100
THEN
SET NEW_AMOUNT = AMOUNT * 1;
ELSE
SET NEW_AMOUNT = AMOUNT *10;
END IF

Here I would want to display NEW_AMOUNT and EMP_ID in each row instead of AMOUNT. any way to acheive this?
_________________
Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Sep 17, 2007 1:35 pm    Post subject: Reply with quote

Sarangadhar,

Define a workstorage variable and perform the calculations on that and display it

Code:

SELECT AMOUNT
      ,EMP_ID
  FROM EMP;

IF AMOUNT > 100 THEN
   COMPUTE WS-AMOUT = AMOUNT * 1
   DISPLAY 'NEW AMOUNT : ' WS-AMOUNT
   SET NEW_AMOUNT   = :WS-AMOUT;
ELSE
   COMPUTE WS-AMOUT = AMOUNT * 10
   DISPLAY 'NEW AMOUNT : ' WS-AMOUNT
   SET NEW_AMOUNT =  :WS-AMOUT;
END IF


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Mon Sep 17, 2007 1:48 pm    Post subject: Reply with quote

kOLUSU,
i would want to perform this in QMF or SPUFI, is it possible to use working storage variables and us COMPURE, DISPLAY statements?

Another approache I remember sometime back on thsi forum is using CASE WHEN in the select statement to modify the column value before display.
_________________
Thanks
Back to top
View user's profile Send private message
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Mon Sep 17, 2007 1:53 pm    Post subject: Reply with quote

Kolusu,
this works. thanks.

SELECT EMP_ID,AMOUNT,
CASE WHEN AMOUNT > 100
THEN CHAR(AMOUNT * 1)
ELSE CHAR(AMOUNT * 10)
END AS NEW_AMOUNT
FROM EMP
_________________
Thanks
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Mon Sep 17, 2007 2:01 pm    Post subject: Reply with quote

The CASE is your best bet. If you're still interested in QMF, there are a couple manuals at IBM's website that would get you going. QMF is not exactly intuitive, but it can create nice reports. There are way better tools available, but if you don't have access to anything else, any port in a storm will do...


http://www-306.ibm.com/software/data/db2/zos/v8books.html
Back to top
View user's profile Send private message
Sarangadhar
Beginner


Joined: 14 Oct 2004
Posts: 130
Topics: 43
Location: virtual village

PostPosted: Mon Sep 17, 2007 4:06 pm    Post subject: Reply with quote

jsharon1248 -
My question is not related to usage of QMF. I would like to get the required output without using application programming constructs so that I can run it on QMF or SPUFI.

Hope you got mine.
_________________
Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group