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 

Cursor with return for

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


Joined: 13 Jan 2006
Posts: 20
Topics: 10

PostPosted: Wed May 06, 2015 5:53 pm    Post subject: Cursor with return for Reply with quote

We have a stored procedure that returns result set to a web service. In addition to the columns selected from tables, I need to also return some computed values that involves complex business logic. I can load the computed host variable (HV1, HV2, HV3) in a new table and join it in the cursor statement, but having a table to hold short lived data is not convincing to me. It also requires table clean up process and DBA overhead. Is there a way to return the host variables in the SQL?
Code:

DECLARE CUSTOMER_CURSOR WITH RETURN FOR
SELECT NAME, ADDR, PHONE,
  CASE WHEN TYPE = 'A'  THEN HV1
       WHEN TYPE = 'B'  THEN HV2
       ELSE HV3
   END COMPLEX_COMPUTED_VAL
  FROM CUST_TABLE
WHERE ...
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Wed May 06, 2015 6:43 pm    Post subject: Reply with quote

When you create the Procedure you can set it up for INOUT.

Sample COBOL stored procedure.
Code:

CREATE PROCEDURE XXXXX.GETXXXXX 
   (INOUT  SSN     INTEGER,
    INOUT  ANSWER  CHAR(01))
    LANGUAGE COBOL                 
   PARAMETER STYLE GENERAL         
   EXTERNAL NAME XXXXXXXXXXXX         
   COLLID XXXXXXXX               
   SECURITY DB2                   
   WLM ENVIRONMENT DSNWLM_GENERAL;

_________________
Thanks,
NASCAR9
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