ommer
asked on
calling stored proc from CF
Hi, dear CF experts,
This my first sp call from CF. I got Invalid CFML construct on last CFIF statement. Here is my cf code and sp itself, which I have tested successfully in sql.
<cfstoredproc datasource="QWSQL" procedure="Web_CheckLastLo gin" returncode="No">
<cfprocresult name="MonthSinceLastLogin" resultset="1">
<CFPROCPARAM TYPE="IN"
DBVARNAME="@p1"
VALUE=login.user_id
CFSQLTYPE="CF_SQL_LONGVARC HAR">
<CFPROCPARAM TYPE="OUT"
DBVARNAME="@MonthSinceLast Login"
Variable = m_Months
CFSQLTYPE="CF_SQL_SMALLINT ">
</cfstoredproc>
<cfif m_Months LG 2>
<cflocation url ="MaintainAcct.cfm?user_id >
</cfif>
CREATE PROCEDURE [dbo].[Web_CheckLastLogin]
@p1 varchar(10) ,
@MonthSinceLastLogin smallint output
AS
SET NOCOUNT ON
select @MonthSinceLastLogin = datediff(mm,
(select max(time_occured) from web_history where script_name ='/cust/login.cfm'
and [user_id] =@p1),
getdate())
return @MonthSinceLastLogin
SET NOCOUNT OFF
GO
Thanks a lot!
This my first sp call from CF. I got Invalid CFML construct on last CFIF statement. Here is my cf code and sp itself, which I have tested successfully in sql.
<cfstoredproc datasource="QWSQL" procedure="Web_CheckLastLo
<cfprocresult name="MonthSinceLastLogin"
<CFPROCPARAM TYPE="IN"
DBVARNAME="@p1"
VALUE=login.user_id
CFSQLTYPE="CF_SQL_LONGVARC
<CFPROCPARAM TYPE="OUT"
DBVARNAME="@MonthSinceLast
Variable = m_Months
CFSQLTYPE="CF_SQL_SMALLINT
</cfstoredproc>
<cfif m_Months LG 2>
<cflocation url ="MaintainAcct.cfm?user_id
</cfif>
CREATE PROCEDURE [dbo].[Web_CheckLastLogin]
@p1 varchar(10) ,
@MonthSinceLastLogin smallint output
AS
SET NOCOUNT ON
select @MonthSinceLastLogin = datediff(mm,
(select max(time_occured) from web_history where script_name ='/cust/login.cfm'
and [user_id] =@p1),
getdate())
return @MonthSinceLastLogin
SET NOCOUNT OFF
GO
Thanks a lot!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cool! I like the 2nd way for its simplicity!
--------------------------
<cfquery datasource="YourDSN" name="MyQuery">
{call dbo.Web_CheckLastLogin ('#login.user_id#')}
</cfquery>
<cfdump var="#MyQuery#"> <!--- dump to see results --->
and have your stored procedure like so....
--------------------------
CREATE PROCEDURE [dbo].[Web_CheckLastLogin]
@p1 varchar(10)
AS
SET NOCOUNT ON
DECLARE @MonthSinceLastLogin smallint
select @MonthSinceLastLogin = datediff(mm,(select max(time_occured) from web_history where script_name ='/cust/login.cfm' and [user_id] =@p1),getdate())
SET NOCOUNT OFF
GO