Using Stored Procs w/ Data Shaping

Using Stored Procs w/ Data Shaping

Post by Dan Clas » Tue, 29 Feb 2000 04:00:00



Hi-

I am using datashaping to create a hierarchy of recordsets based on the
results of several stored procedures.  I am running into trouble with one
that uses a temp table prior to displaying the results.  Is there a way to
utilize stored procedures that use temp tables in datashaping?  When I
execute the shape statement below I get the error invalid object #pivot.

Thank You,
Dan Clash

shape {{call sp_Product_LogsCreated ('1-1fh','01/01/2000','01/31/2000')}}
append ({{call sp_Product_LogsClosed ('1-1fh','01/01/2000','01/31/2000')}}
relate ProductId to ProductId) as Logs,
({{call sp_Product_LogsReactivated ('1-1fh','01/01/2000','01/31/2000')}}
relate ProductId to ProductId) as React,
({{call sp_Product_Backlog ('1-1fh','01/31/2000')}}
relate ProductId to ProductId) as Back

The LogsClosed Stored Proc.

CREATE PROCEDURE [dbo].[sp_Product_LogsClosed]



AS

select ps.ProductID,

         when '1-1HH' then sr.SubGroupId
         when '1-2LHD1' then sr.SubGroupId
         when '1-CB2P' then sr.SubGroupId
         when '1-1G5' then sr.SubGroupId
 else 'Other'
 end as Workgroup,
 sum(datediff(mi,sr.Created, sr.ClosedDate)/1440.) as 'Average',
 Count(sr.Row_ID) as Number
into  #pivot
from  msereport..ServiceRequest sr inner join
 msereport..ProductSubgroup ps on ps.ProductID = sr.ProductID


group by ps.ProductID, sr.SubGroupId

select  p1.*, (p1.Workgroup + p1.HD + p1.Other) as Total
from (select p.ProductId,

Workgroup,
 sum(case p.Workgroup when '1-1hh' then p.Number
              when '1-2LHD1' then p.Number
              when '1-CB2P' then p.Number
              when '1-1G5' then p.Number
 else 0 end) as HD,
 sum(case p.Workgroup when 'Other' then p.Number else 0 end) as Other,
 sum(Average) as 'Average'
 from  #pivot p
 group by p.ProductId) p1

drop table #pivot
GO

 
 
 

1. Returning a shaped ADO.Recordset using Stored Procs

Hi,

I am trying to return a shaped recordset from SQL7 and I hope to use stored
procs.

I know that you cant use a stored proc to generate the shaped recordset, but
I was hoping to use something like this:

    strSQL = ""
    strSQL = strSQL & "SHAPE {usp_PointsAllocRuleGetById ?} "
    strSQL = strSQL & "AS rsPointsAllocRule "
    strSQL = strSQL & "APPEND ({usp_PointsAllocRuleProductsGetById ?} "
    strSQL = strSQL & "AS rsPointsAllocRuleProduct "
    strSQL = strSQL & "RELATE PointsAllocRuleId To PointsAllocRuleId)"

as the commandtext.

It seems to work if the I only use one stored proc asn the parent, and
dynamic sql as the rest. eg:

'    strSQL = ""
'    strSQL = strSQL & "SHAPE {EXEC usp_PointsAllocRuleGetById ?} "
'    strSQL = strSQL & "AS rsPointsAllocRule "
'    strSQL = strSQL & "APPEND ({SELECT  PointsAllocRuleId , ProductCode
FROM PointsAllocRuleProduct WHERE PARP.PointsAllocRuleId = ?} "
'    strSQL = strSQL & "AS rsPointsAllocRuleProduct "
'    strSQL = strSQL & "RELATE PointsAllocRuleId To PointsAllocRuleId)"

If anyone has any ideas on this I'd much appriate it.

Cheers

Gordon Staines

2. Question about Intersolv ODBC Drivers

3. Btrieve error 46 during update

4. Use Stored Procs In Data Shaping?

5. HorrorStory: this one-line component bug cost me 23 days and $2,500!

6. SHAPE Command and Stored Procs

7. SHAPE problem with Stored Procs in SQL Server

8. SHAPE Command and Stored Procs

9. Data shaping problem using stored procedures!

10. Unable to Design tablles, view and stored procs etc using Data View

11. Problem using shape recordsets with stored procedure that uses a temp table