Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:41:56+00:00 2026-05-27T07:41:56+00:00

Does cfquery execute on every page load? I ask because I’m getting a sequence

  • 0

Does cfquery execute on every page load? I ask because I’m getting a sequence number with the query and then using it in a form. Unfortunatly, the query seems to execute every time the page loads. I don’t want that to happen. I also tried putting it inside of a cffunction and then calling it out of the onSubmit parameter of of the cfinput box that uses the sequence number, but it still calls the sequence.

Here are examples of the way I’ve tried to do this:

<cfquery name="payment_seq_num" datasource="ORCL">
        select ratner01.payment_id_seq.nextval as seq from dual
    </cfquery>
  <cfset paymentid = payment_seq_num.seq>

And

<cffunction name="getVetSeq" output="false">
  <cfquery name="vet_seq_num" datasource="ORCL">
        select ratner01.vet_id_seq.nextval as seq from dual
    </cfquery>
  <cfset  vet_form.VET_ID = vet_seq_num.seq>

</cffunction>

I get why the first one keeps incrementing…it’s in the head and is called everytime. But why would the second one execute every page load?

Here’s how I’m calling it:

<cfform action="vet_output.cfm" method="post" format="html" class="cfform" name="vet_form">
    <fieldset>
        <legend>Add a Veterinarian to the Databse</legend> 
    <table>
        <tr><cfoutput>
            <td><cfinput type="hidden" name="VET_ID" onsubmit="#getVetSeq()#"></td></cfoutput>
        </tr>
        <tr>
            <td>Vet First Name:<br/> <cfinput type="text" name="VET_FNAME" maxlength="35"></td>
            <td>Vet Last name: <br/><cfinput type="text" name="VET_LNAME" maxlength="50"></td>
        </tr>
        <td><cfinput type="submit" value="Insert" name="vetSubmit"></td>
    </table>
    </fieldset>
</cfform>

So I added this into the output page and removed all related code from the input page, thanks to some suggestions, and it worked… :

  <cfquery name="vet_seq_num" datasource="ORCL">
            select ratner01.vet_id_seq.nextval as seq from dual
        </cfquery>
  <cfset FORM.VET_ID = vet_seq_num.seq>
  <cfinsert name="insert_vet" datasource="ORCL" username="XX" password="XX"
    tablename="VET"
    formfields="VET_ID, VET_FNAME, VET_LNAME">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:41:57+00:00Added an answer on May 27, 2026 at 7:41 am

    Yeah, so every time this page is loaded you will call that function and get a new sequence number. Because everytime you load the page #getVetSeq()# will be executed by ColdFusion.

    I know you put it in onSubmit() but onSubmit() is a JavaScript event, which has no knowledge of ColdFusion. By the time JavaScript sees that code the function has already been called. If you look you’ll probably see JS errors because when you click submit you are actually calling a non-existant function. Because your code renders as something like:

    onsubmit="1234"
    

    If you only want it called when the form is submitted then do it in your output.cfm instead of in your form.

    If for some reason you need to do it on this page instead of in your processing page, then you’ll need to look at doing it as an Ajax call so that it only executes onSubmit().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does C# have built-in support for parsing strings of page numbers? By page numbers,
When you use the cachedwithin attribute in a cfquery how does it store the
does anyone know any tool for 'code generation' using MVC2? I know that ASP
Does the AppleWWDRCA.cer have any bearing on developing certificates using OpenSSL? If so, what?
Does cfquery becomes a prepared statement as long as there's 1 cfqueryparam ? Or
using CFMX7 and Oracle 10g ent on a query-intensive and active web site, I'm
Does anyone know, what an XMLHttpRequest enables a web page to do, which cannot
Does the JavaScript below allow a webpage load quicker opposed to the a standard
Initial situation: Inside a function I'm caching a query using the cachedWithin attribute. Right
Does anyone know why this bean is getting instantiated multiple times? I only ever

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.