For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

storedproc

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Used to execute a stored procedure in a server database using CFScript. It specifies database connection information and identifies the stored procedure.

Syntax

Mode

Syntax

Creating the service

new storedProc() or createObject("component", "storedproc")

Initializing the attributes

Any one of the following:

  • storedProcService=new storedproc(attribute-value_pair)
  • storedprocService.setAttributes(attribute-value_pair)
  • storedProcService.set_AttributeName_(attribute_value)
  • storedProcService.execute(attribute-value_pair)

Executing the service action

storedProcService.execute(_attribute-value_pair_)

Properties

datasource

procedure

debug

cachedafter

cachedwithin

blockfactor

password

result

returncode

username

 

 

All attributes supported by the tag cfstoredproc are supported as attribute-value pairs. For example,

<cfstoredproc procedure= "sp_proc">

can be used as

spService.setProcedure("sp_proc");

For details of the cfstoredproc tag attributes, see the Attributes section for cfstoredproc__.

See also

cfstoredproc, Function summary

History

ColdFusion 9: Added this function.

Methods

  • addParam

    Description

    Used to add cfprocparam tags.

    Syntax

    storedprocService.addParam(attribute-value pair)

    Returns

    Nothing

    Arguments

    All attributes supported by cfprocparam tag can be used as attribute-value pairs.

     

  • addProcResult

    Description

    Used to add cfprocresult tags to associate a query object with a result set returned by a stored procedure.

    Syntax

    storedprocService.addProcResult(attribute-value pair)

    Returns

    Nothing

    Arguments

    All attributes supported by the cfprocresult tag can be used as attribute-value pairs.

     

  • execute

    Description

    Used to execute a stored procedure.

    Returns

    A component on which the following methods can be invoked:

     

  • getProcResultSets(): To access result sets returned by the procedure.
  • getProcOutVariables(): To access OUT or INOUTvariables returned by the procedure.

    Syntax

    storedprocService.execute(attribute-value pair)

    Arguments

    All attributes supported by the cfstoredproc tag.

     

  • setAttributes

    Description

    Sets attributes for the storedproc function.

    Returns

    Nothing

    Syntax

    storedProcService.setAttributes (attribute-value pair)

    Arguments

    All attributes supported by the cfstoredproc tag.

     

  • getAttributes

    Description

    Gets attributes that were set for the storedproc function.

    Returns

    Returns a struct with all or some of the attribute values.

    Syntax

    storedProcService.get_Attributes_ (attributelist)

    Arguments

    A comma-separated list of attributes. If no list is specified, all defined attributes are returned.

     

  • clearAttributes

    Description

    Removes all attributes added for the storedProc function.

    Returns

    Nothing

    Syntax

    storedProcService.clearAttributes(attribute_list)

    Arguments

    A comma-separated list of attributes.

     

  • clearParams

    Description

    Removes cfprocparam tags added using the addParam method.

    Returns

    Nothing

    Syntax

    storedProcService.clearParams()

    Arguments

    None

     

  • clearProcResults

    Description

    Removes cfprocresult tags added using the addProcResults method.

    Returns

    Nothing

    Syntax

    storedProcService.clearProcResults()

    Arguments

    None

     

  • clear

    Description

    Removes all attributes and params that were added using the methods addProcResults and addParam.

    Returns

    Nothing

    Syntax

    storedProcService.clear()

    Arguments

    None

     

Usage

This function corresponds to the cfstoredproc tag. For usage details, refer to the Usage section for cfstoredproc.

Example

<cfscript>
//If submitting a new book, insert the record and display confirmation
if(isDefined("form.title"))
{
//create a new storedproc service
spService = new storedproc();
//set attributes using implicit setters
spService.setDatasource("books");
spService.setProcedure("Insert_Book");
//add procparams using addParam
spService.addParam(cfsqltype="cf_sql_varchar", type="in",value=form.title);
spService.addParam(cfsqltype="cf_sql_numeric",type="in",value=form.price);
spService.addParam(cfsqltype="cf_sql_date", type="in",value=form.publishDate);
spService.addParam(cfsqltype="cf_sql_numeric",type="out",variable="bookId");
//add procresults using addProcResult
spService.addProcResult(name="rs1",resultset=1);
//execute the stored procedure
result = spService.execute();
//getprocOutVariables() returns any OUT or INOUT varibles added using addParams()
bookId = result.getprocOutVariables().bookId;
//getProcResultSets() returns resultsets added using addProcresult()
listOfBooks = result.getProcResultSets().rs1;
WriteOutput("<h3>List of Books</h3>");
writeDump(listOfBooks);
//output data
WriteOutput("<h3>" & "'" & form.title & "'" & " inserted into database. The ID is " & bookId & ".</h3>");
}
</cfscript>
<cfform action="#CGI.SCRIPT_NAME#" method="post">
<h3>Insert a new book</h3>
<table>
<tr>
<td>Title:</td>
<td><cfinput type="text" size="20" required="yes" name="title"/></td>
</tr>
<tr>
<td>Price:</td>
<td><cfinput type="text" size="20" required="yes" name="price" validate="float" /></td>
</tr>
<tr>
<td>Publish Date:</td>
<td>
<cfinput type="datefield" name="publishdate" mask="mm/dd/yyyy" size="20" ></td>
</tr>
</table>
<input type="submit" value="Insert Book"/>
</cfform>

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices