• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfstoredproc

LEGEND ,
Nov 10, 2006 Nov 10, 2006

Copy link to clipboard

Copied

I am trying to use cfstoreproc to invoke a stored procedure from a CFC.

I pass in 2 variables into the cfprocparam but am getting this error:


I dumped the 2 invokearguments to make sure they are working and they dump
fine.
Any ideas why this isn't working? (my first time trying to use stored
procedures)

Here is the invoke:
<cfobject name="IQ" component="cfcs.IQ.IQweb">
<cfinvoke component="#IQ#" method="NewPassword">
<cfinvokeargument name="username" value="#GetInfo.ACCOUNT_ID#">
<cfinvokeargument name="password" value="#stpassword#">
</cfinvoke>


Here is the CFC:
<cfcomponent>
<cffunction name="NewPassword" access="public" returntype="void">
<cfargument name="username" type="string" required="yes">
<cfargument name="password" type="string" required="yes">
<cfstoredproc procedure="sp_web_changepassword" datasource="sql_abt">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" variable="@Account_ID"
value="#arguments.username#" null="No">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR"
variable="@UnencryptedNewPassword" value="#arguments.password#" null="No">
<cfprocparam type="Out" cfsqltype="CF_SQL_VARCHAR" variable="new_result"
dbvarname>
</cffunction>
</cfcomponent>

Here is the Stored Procedure:
create procedure sp_web_changepassword
@account_ID varchar(8), @UnencryptedNewPassword Varchar(255), @return_code
int OUTPUT
as
declare @EncryptedPassword varchar(255)
-- initialize variables Return code to Account_ID error code
select @Return_code = 6, @EncryptedPassword = ' '
if exists (select * from ABT_ACCOUNTS where Account_ID = @Account_ID)
begin
-- first encrypt entered password
exec sp_encrypt_text @UnencryptedNewPassword, @EncryptedPassword OUTPUT
-- update ABT_ACCOUNTS with new password
UPDATE ABT_ACCOUNTS
Set Password = @EncryptedPassword
where Account_ID = @account_ID
-- return SUCCESS code
select @Return_code = 0
end

GO


TOPICS
Advanced techniques

Views

309

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 12, 2006 Nov 12, 2006

Copy link to clipboard

Copied

Post the error, please.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 12, 2006 Nov 12, 2006

Copy link to clipboard

Copied

LATEST
Wally Kolcz,

The CFC is missing a closing </cfstoredproc> tag. Also the "variable" attribute isn't needed for IN parameters. Using it shouldn't cause an error though.

http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000313.htm#1102102

Try
<cfstoredproc procedure="sp_web_changepassword" datasource="sql_abt">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" value="#arguments.username#">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" value="#arguments.password#">
<cfprocparam type="Out" cfsqltype="CF_SQL_VARCHAR" variable="new_result">
</cfstoredproc>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation