Cfstoredproc
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
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>
Similar Messages
-
MS Access Cfquery or Cfstoredproc parameters declaration?
How do you pass more than one argument to MS Access stored procedure (query) using either CFQuery or CFStoredProc?
Environment: MS Access 2007; Coldfusion 7 Std Edition.
Working example CFQUERY with 1 date value parameter:
<cfquery name="testStoredProc" datasource="cinci_events">
EXEC qry_MenuByDate '2/1/2011'
</cfquery>
(Access query parameter name is "@dtmDate", but its inclusion in EXEC statement creates error).
But an otherwise-same-as query using 2nd date value parameter fails
Error Executing Database Query.
Syntax error (missing operator) in query expression ''2/1/2011' '2/2/2011''.
The error occurred in D:\ciweb\scripts\reservations\cf\dsp_CaféMenu_StoredProcedure3.cfm: line 59
57 : --->
58 : <p> datasource = {<cfoutput>cinci_events</cfoutput>}</p>
59 : <cfquery name="testStoredProc" datasource="cinci_events">
60 : EXEC qry_MenuByDateRange '2/1/2011' '2/2/2011'
61 : </cfquery>
Above query "knows" the existence of 2nd date value. Without a 2nd date, query errors with message:
Error Occurred While Processing Request
Error Executing Database Query.
Parameter [EndDate?] has no default value.
The error occurred in D:\ciweb\scripts\reservations\cf\dsp_CaféMenu_StoredProcedure3a.cfm: line 59
57 : --->
58 : <p> datasource = {<cfoutput>cinci_events</cfoutput>}</p>
59 : <cfquery name="testStoredProc" datasource="cinci_events">
60 : EXEC qry_MenuByDateRange '2/1/2011'
61 : </cfquery>
SQL
EXEC qry_MenuByDateRange '2/1/2011'
DATASOURCE
cinci_events
VENDORERRORCODE
3088
SQLSTATE
Resources:
I would prefer to use a Cfstoredproc method. But help with declaring multiple inputs for either is very much appreciated.
Thank, GuySeparating CFQUERY arguments with a comma corrects the error. I thought (?) I had tried comma separation in my iterations. Thanks.
Many unsuccessful iterations tried with CFSTOREDPROC. For example:
Error Occurred While Processing Request
Error Executing Database Query.
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
The error occurred in D:\ciweb\scripts\reservations\cf\dsp_CaféMenu_StoredProcedure23.cfm: line 65
63 : <cfstoredproc procedure = "qry_MenuByDate" DATASOURCE="cinci_events">
64 : <cfprocparam type="in" cfsqltype="CF_SQL_DATE" dbvarname="dtmDate" value='2/1/2011'>
65 : <cfprocresult name="testStoredProc">
66 : </cfstoredproc>
67 : <p>testStoredProc.RecordCount = {<cfoutput>#testStoredProc.RecordCount#</cfoutput>}</p>
SQL
{call qry_MenuByDate( (param 1) )}
DATASOURCE
cinci_events
VENDORERRORCODE
3092 -
I am having problems with using a cfstoredproc. I am trying
to pass a character chain (cf_sql_varchar) but it gives me an error
message. It doesn't like that I am passing a varchar. When I pass a
numeric value, it works.
I used to have the same code in Coldfusion 5 and it worked
perfectly, now in coldfusion MX, it doesn't work.
Here is the code:
<cfparam name="the_key" default="#form.offname#">
<cfstoredproc procedure="csd_searchkey"
datasource="#Session.MM_datasource#"
returncode="Yes">
<cfprocparam type="InOut"
variable="the_key"
cfsqltype="cf_sql_varchar"
dbvarname="text_offname_param"
value="#the_key#">
</cfstoredproc>
Can anyone help me ?
Thank you very much in advance.<cfstoredproc procedure="xp_GMNewRecid"
dataSource="MasterDB" returnCode="Yes" debug="Yes">
<cfprocparam type = "IN" CFSQLType = "CF_SQL_VARCHAR"
value = "SHA">
<cfprocparam type = "OUT" CFSQLType = "CF_SQL_VARCHAR"
variable ="recID" dbvarname="@recid">
</cfstoredproc>
Regards -
Cfstoredproc - Numeric Overflow Error - CF8
I recently upgraded to CF8 and have started having problems
with cfstoredproc. Here is the code:
<cfstoredproc datasource="#request.myDSN#"
procedure="dbo.p_online_password.get_account" >
<cfprocparam cfsqltype="cf_sql_varchar"
value="#attributes.email#" type="in" maxlength="50">
<cfprocparam cfsqltype="cf_sql_bigint" type="out"
variable="appvars.online_password_id">
<cfprocparam cfsqltype="cf_sql_varchar" type="in"
value="#attributes.password#" maxlength="30">
<cfprocparam cfsqltype="cf_sql_bigint" type="out"
variable="appvars.account_status">
<cfprocparam cfsqltype="cf_sql_varchar" type="out"
variable="appvars.loginmessage" maxlength="500">
<cfprocparam cfsqltype="cf_sql_bigint" type="out"
variable="appvars.personid">
</cfstoredproc>
Here is the logged dbcall:
spy(2007/12/27 15:29:58.361)>> Driver Name = Oracle
spy(2007/12/27 15:29:58.361)>> Driver Version = 3.60.26
(023731.010811.016225)
spy(2007/12/27 15:29:58.361)>> Database Name = Oracle
spy(2007/12/27 15:29:58.361)>> Database Version =
9.2.0.8.0
spy(2007/12/27 15:29:58.361)>> OK (Connection[6])
spy(2007/12/27 15:29:58.361)>>
Connection[6].setTransactionIsolation(int level)
spy(2007/12/27 15:29:58.361)>> level = 2
spy(2007/12/27 15:29:58.361)>> OK
spy(2007/12/27 15:29:58.361)>>
Connection[6].isReadOnly()
spy(2007/12/27 15:29:58.361)>> OK (false)
spy(2007/12/27 15:29:58.361)>>
Connection[6].getAutoCommit()
spy(2007/12/27 15:29:58.361)>> OK (true)
spy(2007/12/27 15:29:58.361)>>
Connection[6].prepareCall(String sql)
spy(2007/12/27 15:29:58.361)>> sql = {call
dbo.p_online_password.get_account(?, ?, ?, ?, ?, ?)}
spy(2007/12/27 15:29:58.377)>> OK
(CallableStatement[1])
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].setObject(int parameterIndex, Object x, int
targetSqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 1
spy(2007/12/27 15:29:58.377)>> x =
[email protected]
spy(2007/12/27 15:29:58.377)>> targetSqlType = 12
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].registerOutParameter(int parameterIndex, int
sqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 2
spy(2007/12/27 15:29:58.377)>> sqlType = -5
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].setObject(int parameterIndex, Object x, int
targetSqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 3
spy(2007/12/27 15:29:58.377)>> x =
spy(2007/12/27 15:29:58.377)>> targetSqlType = 12
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].registerOutParameter(int parameterIndex, int
sqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 4
spy(2007/12/27 15:29:58.377)>> sqlType = -5
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].registerOutParameter(int parameterIndex, int
sqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 5
spy(2007/12/27 15:29:58.377)>> sqlType = 12
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].registerOutParameter(int parameterIndex, int
sqlType)
spy(2007/12/27 15:29:58.377)>> parameterIndex = 6
spy(2007/12/27 15:29:58.377)>> sqlType = -5
spy(2007/12/27 15:29:58.377)>> OK
spy(2007/12/27 15:29:58.377)>>
CallableStatement[1].execute()
spy(2007/12/27 15:29:58.486)>> java.sql.SQLException:
[Macromedia][Oracle JDBC Driver]Numeric overflow. ErrorCode=0
SQLState=HY000
java.sql.SQLException: [Macromedia][Oracle JDBC
Driver]Numeric overflow.
at
macromedia.jdbc.base.BaseExceptions.createException(Unknown Source)
at macromedia.jdbc.base.BaseExceptions.getException(Unknown
Source)
at macromedia.jdbc.oracle.OracleVNU.convertVNUToLong(Unknown
Source)
at
macromedia.jdbc.oracle.OracleImplStatement.convertAndPropagateOutputParams(Unknown
Source)
at
macromedia.jdbc.oracle.OracleImplStatement.execute(Unknown Source)
at macromedia.jdbc.base.BaseStatement.commonExecute(Unknown
Source)
at
macromedia.jdbc.base.BaseStatement.executeInternal(Unknown Source)
at
macromedia.jdbc.base.BasePreparedStatement.execute(Unknown Source)
at
macromedia.jdbc.base.BasePreparedStatementPoolable.execute(Unknown
Source)
at macromedia.jdbcspy.SpyPreparedStatement.execute(Unknown
Source)
at
coldfusion.server.j2ee.sql.JRunPreparedStatement.execute(JRunPreparedStatement.java:89)
at coldfusion.sql.Executive.executeCall(Executive.java:860)
at coldfusion.sql.Executive.executeCall(Executive.java:775)
at coldfusion.sql.Executive.executeCall(Executive.java:726)
at coldfusion.sql.SqlImpl.executeCall(SqlImpl.java:445)
at
coldfusion.tagext.sql.StoredProcTag.executeQuery(StoredProcTag.java:272)
at
coldfusion.tagext.sql.StoredProcTag.doEndTag(StoredProcTag.java:225)
at
cfprocGetAccount2ecfm1970365621.runPage(C:\Inetpub\wwwroot\FBARO\model\login\procGetAccou nt.cfm:63)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:2644)
at
cflogin2eloginuser2ecfm500887643._factor72(C:\Inetpub\wwwroot\FBARO\parsed\login.loginuse r.cfm:24)
at
cflogin2eloginuser2ecfm500887643._factor80(C:\Inetpub\wwwroot\FBARO\parsed\login.loginuse r.cfm:17)
at
cflogin2eloginuser2ecfm500887643._factor81(C:\Inetpub\wwwroot\FBARO\parsed\login.loginuse r.cfm:5)
at
cflogin2eloginuser2ecfm500887643.runPage(C:\Inetpub\wwwroot\FBARO\parsed\login.loginuser. cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:2644)
at
cffusebox52ecfm1910112018.runPage(C:\Inetpub\wwwroot\FBARO\fusebox5.cfm:179)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:2644)
at
cffusebox42eruntime2ecfmx2ecfm1434713790.runPage(C:\Inetpub\wwwroot\FBARO\fusebox4.runtim e.cfmx.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:2644)
at
cfindex2ecfm1115026679.runPage(C:\Inetpub\wwwroot\FBARO\index.cfm:28)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366)
at
coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279)
at
coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74)
at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8)
at
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at
coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at
coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)
at coldfusion.CfmServlet.service(CfmServlet.java:175)
at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 )
at
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
spy(2007/12/27 15:29:58.486)>>
CallableStatement[1].close()
spy(2007/12/27 15:29:58.486)>> OK
spy(2007/12/27 15:29:58.502)>>
Connection[6].setAutoCommit(boolean autoCommit)
spy(2007/12/27 15:29:58.502)>> autoCommit = true
spy(2007/12/27 15:29:58.502)>> OK
spy(2007/12/27 15:29:58.502)>>
Connection[6].setTransactionIsolation(int level)
spy(2007/12/27 15:29:58.502)>> level = 2
spy(2007/12/27 15:29:58.502)>> OK
spy(2007/12/27 15:29:58.502)>>
Connection[6].setReadOnly(boolean readOnly)
spy(2007/12/27 15:29:58.502)>> readOnly = false
spy(2007/12/27 15:29:58.502)>> OK
Any ideas?
Thanks,
JimFYI, there is a table near the bottom of the LiveDocs page
for the
cfqueryparam
tag that "
shows the mapping of ColdFusion SQL data types with JDBC SQL
types and those of the listed database management systems".
(The same mapping applies to the cfprocparam tag as well, and I am
surprised that they don't have it listed there as well.)
You will notice that CF_SQL_BIGINT doesn't map to Oracle, and
that only CF_SQL_DECIMAL and CF_SQL_FLOAT seem to map to Oracle
type number. However, I use CF_SQL_NUMERIC all of the time with
Oracle 10g and Oracle type NUMBER with CF7, but I can't speak for
CF8 since we are still on 7.
Phil -
How to run cfstoredproc in the background
Hi,
I'm looking for a possibility to run an oracle procedure via cfstoredproc
and continue my CF-page immediately afterI starting the procedure.
I need to do that because the procedure sometimes needs more than 10 mintues so that I get
a timeout.
Does anybody has an idea?
regards ClaudiaI tested cfthread, but still I have the same problem like before(page timeout).
Here is what I do:
Start Database procedure to create a data export file. It will be saved on the server.
<cfthread name="t1" action="run" priority="normal">
<cfstoredproc procedure="exp" datasource="test" returncode="no" >
<cfprocparam type="in" dbvarname="id" cfsqltype="cf_sql_integer" value="#url.id#">
</cfstoredproc>
</cfthread>
When the procedure finished, (this can take some minutes), the export file is opened.
If it is a big export I get a page timeout. If the export is fast enough a popup window opens to download or
open the file.
<cfthread name="t1" action="join" />
<cfheader
name="content-disposition" charset="utf-8"
value="attachment; filename=export.txt"
/>
<cfcontent type = "text/plain"
file = "export"
deleteFile = "no">
What's wrong with my code? How to tell the page to wait until the procedure is finished and not to get a timeout? -
Hi. Is there a way to set timeout for the tag
<CFSTOREDPROC>? I mean, for cfquery, it has a parameter
timeout in seconds. How about for CFSTOREDPROC?
I tried using
<cfset startproc = GetTickCount()>
<cfsetting requesttimeout = "20" />
<CFSTOREDPROC PROCEDURE="fsdfsd" DATASOURCE="sfsds">
cfprorparams here.........
</CFSTOREDPROC>
<cfset proc_execute = GetTickCount() - startproc >
proc_execute returns about 30,000 ms which is 30 s. But the
timeout needs to end it in 20 s. It seems requesttimeout doesn't
include the time it took for the stored procedure executing. That
is why I'm looking for a timeout in cfstoredproc. Any suggestions?
I don't wanna go to the Oracle server and set the timeout settings.
I want it done in Coldfusion. Thanks.There is no timeout attribute for cfstoredproc. Since all the
processing is occurring inside the database there is no way for us
to time it out. Also, since we do not know the DBMS in advance we
could not use any DBMS specific means. If Oracle SQL lets you set
it inside the SP, that is your way to go.
RequestTimeout/page timeouts only cover the time CF is in
control of the thread. -
Cfstoredproc performance?
Hello,
In SQL2005, when i use<cfstoredproc></cfstoredproc>
from procedure..if i return result like this without using output parameter...Is there a performance problem?
create procedure tbl_a_list
as
@id_in as int;
select name, address, sal
from tbl_a
where id = @id_in
OR
If i use out parameter for all varibles?..Performance increase with CF?.
create procedure tbl_a_list
as
@id_in as int;
@name varchar(25) output,
@address varchar(25) output,
@sal int output,
select @name=name, @address=address,@sal=sal
from tbl_a
where id = @id_in
Please help me.Hi,
Your first stored procedure looks fine:
CREATE PROCEDURE tbl_a_list
@id_in int
BEGIN
SELECT T.name, T.address, T.sal
FROM tbl_a T
WHERE id = @id_in
END
Use this to call the procedure:
<cfstoredproc datasource="#SESSION.DSN#" procedure="tbl_a_list">
<cfprocparam cfsqltype="cf_sql_integer" type="in" value="#id_in#">
<cfprocresult name="getData">
</cfstoredproc>
cfwild -
MX 7.01 Hotfix 2 - cfstoredproc maxrows not working correctly
Cumulative Hotfix 2 fixed technical note ID 61508 - cfquery,
cfstoredproc maxrows not passed to the JDBC driver (performance
issue on large tables); but it has created a new problem - if you
use "maxrows" for the first result set, then all other result sets
default to maxrows according to the first result set.
If you remove the maxrows setting for the first result set,
then they all work okay. The maxrows setting did not affect the
other result sets until we applied the cumulative Hotfix #2.Cumulative Hotfix 2 fixed technical note ID 61508 - cfquery,
cfstoredproc maxrows not passed to the JDBC driver (performance
issue on large tables); but it has created a new problem - if you
use "maxrows" for the first result set, then all other result sets
default to maxrows according to the first result set.
If you remove the maxrows setting for the first result set,
then they all work okay. The maxrows setting did not affect the
other result sets until we applied the cumulative Hotfix #2. -
Basic Flex to Coldfusion cfstoredproc question
Just starting this ride ...
<cfstoredproc procedure="gmac.sel_smmry_by_mnth(
3,'2001')" datasource="orcl"> called the Oracle proc correctly
with the parms. I then attempted
<cfcomponent>
<cffunction name="getMasterQuery"
output="false"
access="remote">
<cfargument name="rptNum" required="true"
type="Integer">
<cfargument name="yrInput" required="true"
type="String">
returntype="query">
<cfstoredproc procedure="gmac.sel_smmry_by_mnth"
datasource="orcl">
<cfprocresult
name="qSummary">
<cfprocparam type="in"
cfsqltype="CF_SQL_INTEGER"
value = rptNum>
<cfprocparam type="in"
cfsqltype="CF_SQL_VARCHAR"
value = yrInput>
</cfstoredproc>
<cfreturn qSummary>
</cffunction>
</cfcomponent>
with the Flex call
this.dataManager.getMasterQuery(3,"2001"); I get a CFC error
saying
The RPTNUM argument passed to the getMasterQuery function is
not of type Integer. Not sure why I am getting this error - any
help much appreciated,
MicHi,
Try changing your "rptNum" argument declaration's 'type'
attribute as,
<cfargument name="rptNum" required="true"
type="numeric">
and also all your 'cfsqltype="CF_SQL_INTEGER" ' occurences to
"cf_sql_numeric"..
HTH -
Cfstoredproc vs. Exec (SQL Server) or Call (MySQL)
Just out of curiosity...
Why go through the process of adding a cfstoredproc with associated cfprocparams and cfprocresults when I could simply use EXEC or CALL commands?
SQL Server
<cfquery>
exec spMyStoredProc param1,param2
</cfquery>
MySQL
<cfquery>
call spMyStoredProc param1,param2
</cfquery>
It sure would seem to be a lot simpler doing it this way.
Could it have something to do with type validation or database server permissions?As you say, not all DBs will allow query access (indeed: an awful lot of them won't).
Also... try running a proc that returns multiple recordsets using <cfquery>
Plus the JDBC driver handles proc calls one way, and dynamic SQL statements another way.
Using <cfquery> to call a proc is like using a hammer to drive in screws. It's possible, but you're not using the right tool for the job.
Adam -
Last insertID of a cfstoredproc
Is there a way to get the last insertID of a <cfstoredproc >?
Hi,
Change your existing query as,
INSERT INTO [CF].[dbo].[tbComments]
([comment]
,[SAMAccountName]
,[contributingSAMAccountName])
VALUES
@comment,
@SAMAccountName,
@contributingSAMAccountName
SELECT @@IDENTITY As Review_id
And to your stored procedure, do this,
<cfstoredproc procedure="tbComments" dataSource="YOUR_DSN" username="YOUR_USER_NAME" password="YOUR_PASSWORD" dbName="YOUR_DATABASE_NAME" returnCode="Yes" debug="Yes">
<cfprocresult name = RESULT>
<cfprocparam type = "IN" CFSQLType="CF_SQL_VARCHAR" value="VALUE1" dbVarName="@param1">
<cfprocparam type = "IN" CFSQLType="CF_SQL_VARCHAR" value="VALUE2" dbVarName="@param2">
<cfprocparam type = "IN" CFSQLType="CF_SQL_VARCHAR" value="VALUE3" dbVarName="@param3">
<cfprocparam type = "IN" CFSQLType="CF_SQL_VARCHAR" value="VALUE4" dbVarName="@param4">
</cfstoredproc>
<cfoutput>#RESULT.Review_id#</cfoutput>
HTH -
Cannot get all rows from cfProcResult
We upgraded one of our servers (A) from CF 6 to 7.02. Another
server (B) has CF 7.01.
On server B (CF 7.01) the code works (below), all rows of
each dataset are returned.
Now on server A (CF 7.02) all of the resulting datasets have
only the first record in them. If I add maxrows="-1" to each of the
cfProcResult tags there is no change. If I change that to
maxrows="100" then I can get the rows up to 100.
Is this a bug or is there a different means to return all
rows?It think its a bug. I got the same results under MX 7.0.2.
The topic of maxrows recently came up on another thread. I
did some searching and according to TechNote 18339 there was a
change with maxrow
"<cfquery maxrows=N> bug. ColdFusion MX (until ColdFusion
MX 7.0.1 CHF2) didn't pass maxrows to the underlying driver
(statement.setMaxRows())"
Given the results you're getting, it sounds like CF is
applying the maxrow to all of the resultsets, not just the one
where maxrows was declared. I suspect cfstoredproc's usage of
statement.setMaxRows() is incorrect. Thats just a guess though.
Bottom line, I think you'll need handle it manually.
Personally, I would recommend placing the row count logic in the
stored procedure (if possible). The overall results will be more
consistent and you won't have to worry about this kind of issue
again.
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18339
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000314.htm
http://www.remotesynthesis.com/blog/index.cfm/2006/3/23/Maxrows-Issue-in-CFQuery -
Cannot get all updates from iTunes software
Hello. There is a strange problem.
Sometimes, when I open iTunes from my computer, a small number will be displayed after "Apps".
When I click the "Apps", I can also see that there are some updates available from the bottom link text.
But after I click that bottom link, I cannot get all programs which need to be update listed. When I update all listed, iTunes still says there are some apps to be updated, but when I click that bottom link, only a text "No updates are currently available. To check for updates for another Apple ID, sign in with that Apple ID."
At that time, I can get all updates from my iPhone - Apple Store. So all have to do, is update all apps from my iPhone and sync it back. But if some apps are not installed on this iPhone, I have no way to update it.
BTW, I've tried to click Store - Check for available downloads from iTunes on my computer. It's useless in this case.
Any solution? Thanks.It think its a bug. I got the same results under MX 7.0.2.
The topic of maxrows recently came up on another thread. I
did some searching and according to TechNote 18339 there was a
change with maxrow
"<cfquery maxrows=N> bug. ColdFusion MX (until ColdFusion
MX 7.0.1 CHF2) didn't pass maxrows to the underlying driver
(statement.setMaxRows())"
Given the results you're getting, it sounds like CF is
applying the maxrow to all of the resultsets, not just the one
where maxrows was declared. I suspect cfstoredproc's usage of
statement.setMaxRows() is incorrect. Thats just a guess though.
Bottom line, I think you'll need handle it manually.
Personally, I would recommend placing the row count logic in the
stored procedure (if possible). The overall results will be more
consistent and you won't have to worry about this kind of issue
again.
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18339
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000314.htm
http://www.remotesynthesis.com/blog/index.cfm/2006/3/23/Maxrows-Issue-in-CFQuery -
Passing Dynamic Values to a Stored Procedure
I have a stored procedure to create a Table. How to I pass a
value to the procedure to name the Table. This SP works except the
name of the table is @newcomm not the value I am trying to pass in.
What is the proper syntax to make this happen.
CREATE PROCEDURE [dbo].[sp_newcommenttbl]
@newcomm varchar (50)
AS
BEGIN
CREATE TABLE [dbo].[@newcomm] (
[configid] [int] IDENTITY (1, 1) NOT NULL ,
[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[adminemail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[erroremail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[toCommentFormEmail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[gmdsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[dbusername] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbpassword] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath2] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath3] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[urlactivate] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[urlresetpassword] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[initialized] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename1] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename2] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename3] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename4] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename5] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename6] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename7] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename8] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename9] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename10] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[pageheader] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
END
GO
<cfstoredproc procedure="sp_newcommenttbl"
datasource="xxxxx" returncode="no">
<cfprocparam type="in" maxlength="50"
cfsqltype="cf_sql_varchar" value="pighg3">
</cfstoredproc>When I create the procedure I don't get an error. I get an
error when I call it.
[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect
syntax near the keyword 'ON'.
ColdFusion cannot determine the line of the template that
caused this error. This is often caused by an error in the
exception handling subsystem.
Here is the call.
<cfstoredproc procedure="sp_newcommenttbl"
datasource="pisecurity" returncode="no">
<cfprocparam type="in" maxlength="50"
cfsqltype="cf_sql_varchar" value="pighg3" variable="newcomm">
</cfstoredproc>
Here is the syntax for the SP.
CREATE PROCEDURE [dbo].[sp_newcommenttbl]
@newcomm varchar (50)
AS
BEGIN
EXEC('CREATE TABLE [dbo].['+@newcomm+'] (
[configid] [int] IDENTITY (1, 1) NOT NULL ,
[email] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[adminemail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[erroremail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[toCommentFormEmail] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[gmdsn] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL ,
[dbusername] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbpassword] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath2] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[acfcpath3] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[urlactivate] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[urlresetpassword] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[initialized] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename1] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename2] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename3] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename4] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename5] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename6] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename7] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename8] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename9] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[dbtablename10] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL ,
[pageheader] [varchar] (50) COLLATE
SQL_Latin1_General_CP1_CI_AS NULL
ON [PRIMARY]')
END
GO -
I have following code to generate the report for pdf format.
I would like to let users to choose report type 'pdf' or 'excel'
I need pass the user select from user interface to <cfreport format= "PDF" or "Excel".
Can you please advise how I can pass the user select Report Type from lsReportType to my cfReport?
Your help and information is great appreciated,
Regards,
Iccsi
<cfstoredproc procedure="spGetReportType">
<cfprocresult name="rsReportType" resultset="1">
</cfstoredproc>
<cfreport format = "PDF" template= "MyReport.cfr" query="#myQuery#">
</cfreport>
<td><select width="50" name="lstReportType" id="lstReportType">
<cfoutput query="rsReportType">
<option value="#rsReportType.ReportTypeID#" <cfif (isDefined("form.ReportTypeID") AND form.ReportTypeID EQ rsReportType.ReportTypeID)>selected="selected"</cfif>>#rsReportType.ReportType#</option>
</cfoutput>
</select></td>Change format="PDF" to format="#VariableName#" where VariableName contains the text "PDF" or "Excel".
Maybe you are looking for
-
Fan error and excess heat on ENVY DV6t-7200
I have a laptop- ENVY DV6t-1200, product#B6C70AV. Windows 8.1. The computer is only 14 months old, so it is freshly out of warranty. I have been noticing unusually loud fan noise recently. It is not consistent. Sometimes it remains loud for my entire
-
i dont know what to say in way of clarification. when looking at a page i am forced to use the "slide" on the margin which is very sensitive on very long documents instead of the down arrow to move one line. pressing the arrow results in going to the
-
How to resolve security sandbox violation (Error#2148) in Flex 3 on XP?
Hi, When I tried to access an image on c:\ (on XP), I get the following error: *** Security Sandbox Violation *** Connection to file:///C:\DBFiles\3.jpg halted - not permitted from http://localhost/test-debug/test.swf -- Remote SWFs may not access lo
-
Hi, I am trying to build my Flex app which uses the Advanced Data Grid in a couple of locations. Originally, when I built the app using the flex ant tasks, I noticed the Visualization Trial watermark show up on the screen. I then added the licens
-
Hi all I have a nextensio list on a page. is there a way to change the background color of a whore row based on a specific field content? example I have a field containing the values 0 or 1. If the field content is 1 the row background color should b