Go Premium for a chance to win a PS4. Enter to Win

x
?
Private

DB2 Result set from a SP into a Global Temp table not returning all the rows

Posted on 2017-04-18
6
Medium Priority
?
55 Views
Last Modified: 2017-07-31
Hi,

  I have a Stored Procedure, which returns 15 fields.
I wanted to capture the results from that SP, store it in a Global Temp table, and filter for a where condition.
When i call the second SP, it is not returning all the records it's supposed to return.

Attaching the code i wrote. Can someone help me understand what the issue may be?
0
Comment
Question by:pvsbandi
  • 3
6 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 42097961
Hi pvsbandi....

I don't see an attachment.  :)
0
 

Author Comment

by:pvsbandi
ID: 42097995
0
 

Author Comment

by:pvsbandi
ID: 42097998
Sorry, forgot in my original.Added in my earlier post.
Please check.

I want to see how i can fetch the variables and return the data, without using a temp table.
0
 
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 42126739
Hi!

You can do two things.
1) Check the results in the Global Temp table or the source table to see if all the data you expect does match  the query (does all the data have the value 'Client' in the column CL_TYPE)
SELECT * FROM SESSION.GTT_CLIENT_SEARCH_RESULTS
 WHERE LTRIM(RTRIM(CL_TYPE)) = 'Client';

Open in new window

2) Change the procedure P1 so that you return the cursor to client directly after calling the SP
Something like
P1... 
CALL sp_person_search1(vs_first_nm,
                               vs_last_nm,
                               vdt_dob,
                               vi_age,
                               vi_ssn,
                               vi_gender
                              );

ASSOCIATE RESULT SET LOCATOR (V_RS)
WITH PROCEDURE sp_person_search1;

ALLOCATE C_CUR CURSOR FOR RESULT SET V_RS WITH RETURN TO CLIENT;
OPEN C_CUR;
END P1

Open in new window


Regards,
     Tomas Helgi
0
 

Author Comment

by:pvsbandi
ID: 42146934
Hi Tomas,

   
 ALLOCATE C_CUR CURSOR FOR RESULT SET V_RS WITH RETURN TO CLIENT; 

Open in new window

This is not recognised by the DB2 engine.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question