Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 25

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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 …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

722 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