Sample query for return multiple type of output from Store Procedure - proved to be a solution
USE [EdPlan_DEV]
if OBJECT_ID('EdPlanAdm.sxuSearchSampleProc') is not null
drop proc EdPlanAdm.sxuSearchSampleProc
go
drop proc EdPlanAdm.sxuSearchSampleProc
go
CREATE PROCEDURE [EdPlanAdm].[sxuSearchSampleProc]
@filter Nvarchar(1024),
@myoutput int output
AS
@filter Nvarchar(1024),
@myoutput int output
AS
BEGIN
-- start of block 2: will return the count of the result --
DECLARE @count_sql Nvarchar(1024);
set @count_sql = N'select @myoutput = count(*) from dbo.sysobjects where id in ( ' + @filter + ');'
-- start of block 2: will return the count of the result --
DECLARE @count_sql Nvarchar(1024);
set @count_sql = N'select @myoutput = count(*) from dbo.sysobjects where id in ( ' + @filter + ');'
-- output count of matched data
exec sp_executesql @count_sql,N'@myoutput int OUTPUT',@myoutput output;
exec sp_executesql @count_sql,N'@myoutput int OUTPUT',@myoutput output;
select * from dbo.sysobjects ;
END
GO
GO
ColdFusion Codes
cfstoredproc procedure="edplanadm.sxuSearchSampleProc" datasource="#sDataSource#" returnCode = "YES">
<cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR" dbvarname="filter" value="3,5,7">
<cfprocparam type="OUT" cfsqltype="CF_SQL_INTEGER" dbvarname="myoutput" variable="ID"> <!--- these in and out are required by coldfusion. Need to let the store procedure know the type of the parameters --->
<cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR" dbvarname="filter" value="3,5,7">
<cfprocparam type="OUT" cfsqltype="CF_SQL_INTEGER" dbvarname="myoutput" variable="ID"> <!--- these in and out are required by coldfusion. Need to let the store procedure know the type of the parameters --->
<cfprocresult name="query1Result" resultSet=1> <!--- 1 matched the first select statement in the store procedure --->
</cfstoredproc>
Comments
Post a Comment