473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

reporting services - query from stored procedure returns one recor

hi all,
thanks for everyone for your support!

i have a report being built in studio 2005. It calls a stored procedure. The
SP runs a query and gets a data set which then loops through to get other
data. At the end the stored procedure cursor returns several data sets.

my problem is that the report services appears to be reading only the data
returned from the first loop of the cursor inside the stored procedure. It
does not return the other result. Can anyone explain how i can retrieve the
other data sets the store procured cursor should be sending out? I have
tested the SP and makde sure it DOES return more than one result.

here is the sp in case you need to see it.:

CREATE PROCEDURE spRetrieveDoorCardDataForAllLabs AS
begin
declare @LOCATION_ID int
declare @Building varchar(100), @Room varchar(20), @Department varchar(100)
declare @Primaryempno bigint, @PrimaryContact varchar(50)
declare @PrimaryOfficePhone varchar(20), @PrimaryHomePhone varchar(20)
declare @Secondaryempno bigint, @SecondaryContact varchar(50)
declare @SecondaryOfficePhone varchar(20), @SecondaryHomePhone varchar(20)
declare @BuildingAlias varchar(20)

declare get_loc_id cursor for
SELECT TOP 10 LOCATION.LOCATION_ID
FROM
LOCATION INNER JOIN LOCATION_LOCATIONUSAGE ON LOCATION.LOCATION_ID =
LOCATION_LOCATIONUSAGE.LOCATION_ID
INNER JOIN LOCATION_USAGE ON LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID =
LOCATION_USAGE.LOCATION_USAGE_ID
WHERE
(LOCATION_USAGE.GROUP_ID = 1) AND
(LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID = 131)
order by LOCATION.LOCATION_ID

open get_loc_id
fetch next from get_loc_id into @LOCATION_ID

while @@fetch_status = 0
begin
--BEGIN CURSOR LOOP
--************************************************** *************************************
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME,
@BuildingAlias = UNR_ALIAS_ID
FROM viewLocationsForDoorCardReport
WHERE (LOCATION_ID = @LOCATION_ID)

-- This section lookups up the Building Name, Room and Department
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 4 OR
CONTACT_TYPE_ID = 7 OR
CONTACT_TYPE_ID = 2)

-- This section looks up the Primary Emergency contact name and Office
phone Number
SELECT @PrimaryContact = Contact_First + ' ' + Contact_Last,
@PrimaryOfficePhone = PHONE_NUMBER, @Primaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the primary emergency
contact
SELECT @PrimaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(EMPNO = @Primaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

-- This section looks up the Secondary Emergency contact name and Office
phone Number
SELECT @SecondaryContact = Contact_First + ' ' + Contact_Last,
@SecondaryOfficePhone = PHONE_NUMBER, @Secondaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the Secondary
emergency contact
SELECT @SecondaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(EMPNO = @Secondaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

select @Building as Building, @Room as Room, @Department as Dept,
@LOCATION_ID AS LOCATION_ID, @BuildingAlias as UNRAliasID,
@PrimaryContact as PrimaryContact, @PrimaryOfficePhone as
PrimaryOfficePhone, @PrimaryHomePhone as PrimaryHomePhone,
@SecondaryContact as AlternateContact, @SecondaryOfficePhone as
SecondaryOfficePhone, @SecondaryHomePhone as SecondaryHomePhone

--************************************************** *************************************
--END CURSOR LOOP
fetch next from get_loc_id into @LOCATION_ID
end
close get_loc_id
deallocate get_loc_id

end
GO

May 30 '06 #1
2 2594
Select all of the records in the cursor loop (argh!*) into a temp location,
like a table variable or, if you must, a pound temp table (temporary temp
table, not global, which is pound pound): #tempTable. Then select all the
records with a single select after the cursor.

reporting services is probably getting all of the data, but it sees each of
the results as a separate table and only handles table one. This is, BTW,
extremely normal.

* I would choose something other than a cursor to do this, like building the
denormalized data in temp tables or table variables

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"andres" <an****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
hi all,
thanks for everyone for your support!

i have a report being built in studio 2005. It calls a stored procedure.
The
SP runs a query and gets a data set which then loops through to get other
data. At the end the stored procedure cursor returns several data sets.

my problem is that the report services appears to be reading only the data
returned from the first loop of the cursor inside the stored procedure. It
does not return the other result. Can anyone explain how i can retrieve
the
other data sets the store procured cursor should be sending out? I have
tested the SP and makde sure it DOES return more than one result.

here is the sp in case you need to see it.:

CREATE PROCEDURE spRetrieveDoorCardDataForAllLabs AS
begin
declare @LOCATION_ID int
declare @Building varchar(100), @Room varchar(20), @Department
varchar(100)
declare @Primaryempno bigint, @PrimaryContact varchar(50)
declare @PrimaryOfficePhone varchar(20), @PrimaryHomePhone varchar(20)
declare @Secondaryempno bigint, @SecondaryContact varchar(50)
declare @SecondaryOfficePhone varchar(20), @SecondaryHomePhone varchar(20)
declare @BuildingAlias varchar(20)

declare get_loc_id cursor for
SELECT TOP 10 LOCATION.LOCATION_ID
FROM
LOCATION INNER JOIN LOCATION_LOCATIONUSAGE ON LOCATION.LOCATION_ID =
LOCATION_LOCATIONUSAGE.LOCATION_ID
INNER JOIN LOCATION_USAGE ON LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID =
LOCATION_USAGE.LOCATION_USAGE_ID
WHERE
(LOCATION_USAGE.GROUP_ID = 1) AND
(LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID = 131)
order by LOCATION.LOCATION_ID

open get_loc_id
fetch next from get_loc_id into @LOCATION_ID

while @@fetch_status = 0
begin
--BEGIN CURSOR LOOP
--************************************************** *************************************
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME,
@BuildingAlias = UNR_ALIAS_ID
FROM viewLocationsForDoorCardReport
WHERE (LOCATION_ID = @LOCATION_ID)

-- This section lookups up the Building Name, Room and Department
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 4 OR
CONTACT_TYPE_ID = 7 OR
CONTACT_TYPE_ID = 2)

-- This section looks up the Primary Emergency contact name and Office
phone Number
SELECT @PrimaryContact = Contact_First + ' ' + Contact_Last,
@PrimaryOfficePhone = PHONE_NUMBER, @Primaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the primary emergency
contact
SELECT @PrimaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(EMPNO = @Primaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

-- This section looks up the Secondary Emergency contact name and Office
phone Number
SELECT @SecondaryContact = Contact_First + ' ' + Contact_Last,
@SecondaryOfficePhone = PHONE_NUMBER, @Secondaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the Secondary
emergency contact
SELECT @SecondaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(EMPNO = @Secondaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

select @Building as Building, @Room as Room, @Department as Dept,
@LOCATION_ID AS LOCATION_ID, @BuildingAlias as UNRAliasID,
@PrimaryContact as PrimaryContact, @PrimaryOfficePhone as
PrimaryOfficePhone, @PrimaryHomePhone as PrimaryHomePhone,
@SecondaryContact as AlternateContact, @SecondaryOfficePhone as
SecondaryOfficePhone, @SecondaryHomePhone as SecondaryHomePhone

--************************************************** *************************************
--END CURSOR LOOP
fetch next from get_loc_id into @LOCATION_ID
end
close get_loc_id
deallocate get_loc_id

end
GO

May 31 '06 #2
Thank you Cowboy! Why didn't I think of that!!! I'll give it a try!

"Cowboy (Gregory A. Beamer)" wrote:
Select all of the records in the cursor loop (argh!*) into a temp location,
like a table variable or, if you must, a pound temp table (temporary temp
table, not global, which is pound pound): #tempTable. Then select all the
records with a single select after the cursor.

reporting services is probably getting all of the data, but it sees each of
the results as a separate table and only handles table one. This is, BTW,
extremely normal.

* I would choose something other than a cursor to do this, like building the
denormalized data in temp tables or table variables

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"andres" <an****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
hi all,
thanks for everyone for your support!

i have a report being built in studio 2005. It calls a stored procedure.
The
SP runs a query and gets a data set which then loops through to get other
data. At the end the stored procedure cursor returns several data sets.

my problem is that the report services appears to be reading only the data
returned from the first loop of the cursor inside the stored procedure. It
does not return the other result. Can anyone explain how i can retrieve
the
other data sets the store procured cursor should be sending out? I have
tested the SP and makde sure it DOES return more than one result.

here is the sp in case you need to see it.:

CREATE PROCEDURE spRetrieveDoorCardDataForAllLabs AS
begin
declare @LOCATION_ID int
declare @Building varchar(100), @Room varchar(20), @Department
varchar(100)
declare @Primaryempno bigint, @PrimaryContact varchar(50)
declare @PrimaryOfficePhone varchar(20), @PrimaryHomePhone varchar(20)
declare @Secondaryempno bigint, @SecondaryContact varchar(50)
declare @SecondaryOfficePhone varchar(20), @SecondaryHomePhone varchar(20)
declare @BuildingAlias varchar(20)

declare get_loc_id cursor for
SELECT TOP 10 LOCATION.LOCATION_ID
FROM
LOCATION INNER JOIN LOCATION_LOCATIONUSAGE ON LOCATION.LOCATION_ID =
LOCATION_LOCATIONUSAGE.LOCATION_ID
INNER JOIN LOCATION_USAGE ON LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID =
LOCATION_USAGE.LOCATION_USAGE_ID
WHERE
(LOCATION_USAGE.GROUP_ID = 1) AND
(LOCATION_LOCATIONUSAGE.LOCATION_USAGE_ID = 131)
order by LOCATION.LOCATION_ID

open get_loc_id
fetch next from get_loc_id into @LOCATION_ID

while @@fetch_status = 0
begin
--BEGIN CURSOR LOOP
--************************************************** *************************************
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME,
@BuildingAlias = UNR_ALIAS_ID
FROM viewLocationsForDoorCardReport
WHERE (LOCATION_ID = @LOCATION_ID)

-- This section lookups up the Building Name, Room and Department
SELECT @Building = PARENT, @Room = LOCATION_NAME, @Department = DNAME
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 4 OR
CONTACT_TYPE_ID = 7 OR
CONTACT_TYPE_ID = 2)

-- This section looks up the Primary Emergency contact name and Office
phone Number
SELECT @PrimaryContact = Contact_First + ' ' + Contact_Last,
@PrimaryOfficePhone = PHONE_NUMBER, @Primaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the primary emergency
contact
SELECT @PrimaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 8) AND
(EMPNO = @Primaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

-- This section looks up the Secondary Emergency contact name and Office
phone Number
SELECT @SecondaryContact = Contact_First + ' ' + Contact_Last,
@SecondaryOfficePhone = PHONE_NUMBER, @Secondaryempno = empno
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(PHONE_TYPE_DESCRIPTION = 'office')

-- This section looks up the "Home" phone number for the Secondary
emergency contact
SELECT @SecondaryHomePhone = PHONE_NUMBER
FROM viewContacts
WHERE (LOCATION_ID = @LOCATION_ID) AND (CONTACT_TYPE_ID = 9) AND
(EMPNO = @Secondaryempno) AND (PHONE_TYPE_DESCRIPTION = 'home')

select @Building as Building, @Room as Room, @Department as Dept,
@LOCATION_ID AS LOCATION_ID, @BuildingAlias as UNRAliasID,
@PrimaryContact as PrimaryContact, @PrimaryOfficePhone as
PrimaryOfficePhone, @PrimaryHomePhone as PrimaryHomePhone,
@SecondaryContact as AlternateContact, @SecondaryOfficePhone as
SecondaryOfficePhone, @SecondaryHomePhone as SecondaryHomePhone

--************************************************** *************************************
--END CURSOR LOOP
fetch next from get_loc_id into @LOCATION_ID
end
close get_loc_id
deallocate get_loc_id

end
GO


May 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amy B | last post by:
Hi, A co-worker is creating a vb.net web application which uses the CryptKeeper.dll to encrypt credit card numbers into a sql database. It is my job to pull these encrypted numbers and use the...
3
by: Paul Say | last post by:
I have a asp.net application that will need to create a document/report from data in a database. The user will fill out a form supplying various criteria for parameters. I would like the...
8
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string...
5
by: Nesa | last post by:
I have a stored procedure that wraps a moderately complex query over 5, 6 related tables. The performance of the procedure is unacceptably slow as it takes on average 5-10 min to complete. To...
2
by: kbutterly | last post by:
Good afternoon, I have what appears to be a caching issue, but i'm a bit of a newbie at http headers so it may be something else. I have a small asp.net 2.0 application that is called to serve...
0
by: Brian Tkatch | last post by:
In case anyone finds this helpful: Microsoft SQL Reporting Services (SRS) works with DB2, but parameters for stored PROCEDUREs do not, as It does not pull a list of them from DB2. The problem,...
2
by: steveschoonover | last post by:
I wrote a SQL Stored procedure on the Iseries (AS400) V5R4 in Iseries Navigator and I am trying to call it from 2005 SQL Reporting Services and I am trying to use the OLE DB managed provider from IBM...
3
by: jtrapat1 | last post by:
Im using sql server 2005 and visual studio 2005. I just want to create some reports and deploy them to the local reportserver for an intranet application by using reporting services. I'd like to...
2
by: napstar | last post by:
I have a stored procedure in created in oracle(pl sql).I'd like call that stored procedure in SQL Server Reporting services.How do I accomplish this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.