insert statement runs twice in place of once

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default insert statement runs twice in place of once

    Hi

    I am using a simple insert statement .The insert statement picks a variable
    from the form and inserts it into the database.
    I have no loops in the page
    the code is :
    <cfif isdefined("Form.Category")>
    <cfquery name="InsertCat" datasource="ShoppingCart">
    Insert Into ShoppingMstCategory(Category)
    Values('#Form.Category#')
    </cfquery>
    </cfif>

    The insert runs twice on its own.
    Though if I use Query analyser to insert the statement only inserts once.
    am I missing something

    Thanks

    Anj01 Guest

  2. Similar Questions and Discussions

    1. Help with INSERT INTO statement
      I'm getting the following error on a query. I haven't seen this one before. Any ideas on what I'm doing wrong? Thanks. Error Executing Database...
    2. insert statement into a mySQL dB from PHP
      I have an insert statement into a mySQL db from PHP 99% of the time the statement executes properly but occasionally no write to the db occurs,...
    3. INSERT statement contains fewer items than the insert list
      The block of code below shows how I am inserting field values into my dbase table: strSQLStatement = "INSERT INTO tblArticles...
    4. Insert 100 rows in just one statement
      Your auxiliary table is probably the best way. Populate it with as many rows as you like rather than doing multiple inserts when you need more than...
    5. Insert Statement help
      Hello, I am having some difficulty keeping my data consistent throughout my tables. I have 3 tables that I need to be "synch'd up"....
  3. #2

    Default Re: insert statement runs twice in place of once

    Paste your whole page. This snippet is not enough to go on.
    Kronin555 Guest

  4. #3

    Default Re: insert statement runs twice in place of once

    here is the whole page

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>cat update</title>
    </head>

    <body>
    <cfif isdefined("Form.Category")>
    <cfquery name="InsertCat" datasource="ShoppingCart">
    Insert Into ShoppingMstCategory(Category)
    Values('#Form.Category#')
    </cfquery>
    <cfelse>
    <cfif isdefined("Form.CategoryEdit")>
    <cfquery datasource="Shoppingcart">
    UPDATE ShoppingMstCategory
    SET
    [Category] = '#Form.Category#'
    WHERE CategoryID = #Form.EditId#
    </cfquery>
    </cfif>
    </cfif>

    </body>
    </html>


    Anj01 Guest

  5. #4

    Default Re: insert statement runs twice in place of once

    So this page is the action on a form post? Are users double-clicking the submit
    button on the form?

    There's nothing on this page that would cause a double-insert. If this page is
    being posted to twice, that would cause a double insert.

    Kronin555 Guest

  6. #5

    Default Re: insert statement runs twice in place of once

    It does sound like it might be a double post problem.

    If the values in the table should be unique, you might consider making the
    insert conditional so that the form value is only inserted if it does not
    already exist in the table.





    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139