what is wrong with my select for the retrieval of function data - getting error 216

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cheryl culwell
    New Member
    • Dec 2010
    • 4

    #1

    what is wrong with my select for the retrieval of function data - getting error 216

    USE [PATEST]
    GO
    /****** Object: StoredProcedure [dbo].[ndform5queryfor xml] Script Date: 12/22/2010 09:03:12 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFI ER ON
    GO
    -- =============== =============== ===============
    -- Author: cculwell
    -- Create date: 10/29/10
    -- Description: nd form 5 query
    -- =============== =============== ===============
    ALTER PROCEDURE [dbo].[ndform5queryfor xml]
    -- Add the parameters for the stored procedure here
    @YearMonth VARCHAR(20) = ''
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    SELECT [dbo].[ufn.GetWellSumm aryInformation] ( [WellID], [YrMonth], [AllocBegInvento ry], [AllocEndInvento ry], [AllocOil], [DaysOn],
    [AllocOilSold], [AllocOilUsed], [AllocWater] )FROM [dbo].[ufn.GetWellSumm aryInformation] AS [WellID], [YrMonth], [AllocBegInvento ry], [AllocEndInvento ry], [AllocOil], [DaysOn],
    [AllocOilSold], [AllocOilUsed], [AllocWater] where (wellid is Not null)



    -- Insert statements for procedure here
    SELECT Company_Info.Na me as CompName, Co_Info.Contact Street as CompAddress,Co_ Info.ContactSui te as CompSuite, Company_Info.Ci ty as CompCity, Company_Info.St ate as CompState, Company_Info.Zi p as CompZip, Co_Info.Company ID as Company,Co_Info .ContactFirstNa me as ContactfirstNam e,Co_Info.Conta ctLastName as ContactlastName , Co_Info.Contact Phone as ContactPhone, Co_Info.Contact Title as ContactTitle, Co_Info.RptAmen d as facAmend, Co_Info.RptComm ent as FacComment, Wells.APICode as FacId, Well_Summary.Ye arMonth as facreport, Co_Info.RptFacT ype as FacType, Wells.UserField 9 as FacFormation, Wells.WellName as FacName, Wells.Status as FacGroup, Co_Info.RptProd Type as ProdType, round(Well_Summ ary.AllocBegInv entory,0) as prodbeginv,
    round(Well_Summ ary.AllocEndInv entory,0) as prodendinv,Co_I nfo.RptUnits as produnits, round(Well_Summ ary.AllocOil,0) as prodquantity, Well_Summary.Da ysOn as proddaysproduci ng, Co_Info.RptDisp Type1 as disptype, round(Well_Summ ary.AllocOilSol d,0) as oilsolddispqty, Co_Info.RptDisp Type2 disptype2,
    round(Well_Summ ary.AllocOilSol d,0) as dispquantity2, Co_Info.RptDisp Type3 as disptype3, round(Well_Summ ary.AllocOilUse d,0) as dispquantity3, Co_Info.RptProd Type1 as prodtype1, Co_Info.RptUnit s as produnits1, round(Well_Summ ary.AllocWater, 0) as waterprodqty,.
    Well_Summary.Da ysOn as proddaysproduci ng1, Wells.State AS Wstate, Wells.WellOpera tor as WellOperator, Wells.Status as wstatus, Leases.ClientId as lclient
    FROM Wells INNER JOIN
    Leases ON Wells.LeaseID = Leases.LeaseID CROSS JOIN
    Well_Summary CROSS JOIN Co_Info CROSS JOIN
    Company_Info inner join
    dbo.ufnGetWellS ummaryInformati on on Wells.Wellid = wellid
    WHERE (Leases.ClientI D = 15) AND (Wells.WellOper ator LIKE 'PETRO%') AND (Wells.State = 'ND') AND (Wells.APICode IS NOT NULL)
    AND (Wells.Status NOT LIKE '%P&A%') AND (Well_Summary.Y earMonth=@YearM onth) AND (Co_Info.Report Id = 'ND5')
    ORDER BY Wells.APICode, Wells.WellName
    END
    getting the following error:
    Msg 216, Level 16, State 1, Procedure ndform5queryfor xml, Line 29
    Parameters were not supplied for the function 'dbo.ufnGetWell SummaryInformat ion'.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can't select from a stored procedure, you will need to create a temp table, insert into the temp table, and then select from that.

    Comment

    Working...