<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFSTOREDPROC</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFSTOREDPROC</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Executes a stored procedure in a server database. It specifies database connection information and identifies the stored procedure.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
Database manipulation tags
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">Syntax</span><pre>&lt;cfstoredproc 
   procedure = &quot;procedure name&quot;
   dataSource = &quot;ds_name&quot;
   username = &quot;username&quot;
   password = &quot;password&quot;
   blockFactor = &quot;blocksize&quot;
   debug = &quot;yes&quot; or &quot;no&quot;
   returnCode = &quot;yes&quot; or &quot;no&quot;&gt;
result = &quot;result_name&quot;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfinsert, cfqueryparam, cfprocparam, cfprocresult, cftransaction, cfquery, cfupdate; "Optimizing database use" in Chapter&#160;13, "Designing and Optimizing a ColdFusion&#160;Application," in ColdFusion MX Developer's Guide
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX&#160;7: Added the result attribute.
</p>

<p>
ColdFusion&#160;MX: Deprecated the connectString, dbName, dbServer, dbtype, provider, and providerDSN attributes. They do not work, and might cause an error, in releases later than ColdFusion 5. (ColdFusion MX uses Type 4 JDBC drivers.)
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
Use this tag to call a database stored procedure. Within this tag, you code cfprocresult and cfprocparam tags as follows:
</p>
<ul>

<li>cfprocresult&#160;If the stored procedure returns one or more result sets, code one cfprocresult tag per result set.</li>

<li>cfprocparam&#160;If the stored procedure uses input or output parameters, code one cfprocparam tag per parameter, ensuring that you include every parameter in the stored procedure definition. Additionally, you must code cfprocparam tags in the same order as the parameters in the stored procedure definition.</li>
</ul>

<p>
If you set returnCode = &quot;Yes&quot;, this tag sets the variable prefix.statusCode, which holds the status code for a stored procedure. Status code values vary by DBMS. For the meaning of code values, see your DBMS documentation. 
</p>

<p>
This tag sets the variable prefix.ExecutionTime, which contains the execution time of the stored procedure, in milliseconds.
</p>

<p>
The value of prefix is either cfstoredproc or the value specified by the result attribute, if it is set. The result attribute provides a way for stored procedures that are called from multiple pages, possibly at the same time, to avoid overwriting the results of one call with another. If you set the result attribute to myResult, for example, you would access ExecutionTime as myResult.ExecutionTime. Otherwise, you would access it as cfstoredproc.ExecutionTime.
</p>

<p>
Before implementing this tag, ensure that you understand stored procedures and their usage. 
</p>

<p>
The following examples use a Sybase stored procedure; for an example of an Oracle 8 or 9 stored procedure, see cfprocparam.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;!--- This view-only example executes a Sybase stored procedure that 
returns three result sets, two of which we want. The stored 
procedure returns the status code and one output parameter, 
which we display. We use named notation for the parameters. ---&gt;
&lt;!--- 
&lt;cfstoredproc procedure = &quot;foo_proc&quot;
   dataSource = &quot;MY_SYBASE_TEST&quot; username = &quot;sa&quot;
   password = &quot;&quot; dbServer = &quot;scup&quot; dbName = &quot;pubs2&quot;
   returnCode = &quot;Yes&quot; debug = &quot;Yes&quot;&gt;
   &lt;cfprocresult name = RS1&gt;
   &lt;cfprocresult name = RS3 resultSet = 3&gt;

   &lt;cfprocparam type = &quot;IN&quot;       CFSQLType = CF_SQL_INTEGER
         value = &quot;1&quot; dbVarName = @param1&gt;
   &lt;cfprocparam type = &quot;OUT&quot; CFSQLType = CF_SQL_DATE
      variable = FOO dbVarName = @param2&gt;
&lt;/cfstoredproc&gt;
---&gt;
&lt;!--- 
&lt;cfoutput&gt;   The output param value: '#foo#'&lt;br&gt;&lt;/cfoutput&gt;
&lt;h3&gt;The Results Information&lt;/h3&gt;
&lt;cfoutput query = RS1&gt;#name#,#DATE_COL#&lt;br&gt;&lt;/cfoutput&gt;&lt;p&gt;
&lt;cfoutput&gt;
   &lt;hr&gt;
   &lt;p&gt;Record Count: #RS1.recordCount# &gt;p&gt;Columns: #RS1.columnList#   &lt;hr&gt;
&lt;/cfoutput&gt; 
&lt;cfoutput query = RS3&gt;#col1#,#col2#,#col3#&lt;br&gt;
&lt;/cfoutput&gt;&lt;p&gt;
&lt;cfoutput&gt;
   &lt;hr&gt;
   &lt;p&gt;Record Count: #RS3.recordCount# &lt;p&gt;Columns: #RS3.columnList#   &lt;hr&gt;
   The return code for the stored procedure is: '#cfstoredproc.statusCode#'&lt;br&gt;
&lt;/cfoutput&gt;
---&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="PROCEDURE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PROCEDURE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Name of stored procedure on database server.</p>

  </td>
  </tr>
  </table>
</div>
<div id="DATASOURCE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DATASOURCE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Name of data source that points to database that contains stored procedure.</p>

  </td>
  </tr>
  </table>
</div>
<div id="USERNAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">USERNAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Overrides username in data source setup.</p>

  </td>
  </tr>
  </table>
</div>
<div id="PASSWORD">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PASSWORD</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Overrides password in data source setup.</p>

  </td>
  </tr>
  </table>
</div>
<div id="BLOCKFACTOR">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">BLOCKFACTOR</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "1"


<p>Maximum number of rows to get at a time from server. Range is 1 to 100. </p>

  </td>
  </tr>
  </table>
</div>
<div id="DEBUG">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DEBUG</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "No"

<ul>

<li>Yes: lists debug information on each statement.</li>

<li>No</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="RETURNCODE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">RETURNCODE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "No"

<ul>

<li>Yes: populates cfstoredproc.statusCode with status code returned by the stored procedure. </li>

<li>No</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="RESULT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">RESULT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Specifies a name for the structure in which cfstoredproc returns the statusCode and ExecutionTime variables. If set, this value replaces cfstoredproc as the prefix to use when accessing those variables. For more information, see the Usage section.</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
