Getting the ID you just wrote to a table with

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Getting the ID you just wrote to a table with

    Just curious on how to do something when I'm writing with one form, to two
    different tables. I have the unique id that increments in the first table. The
    problem is in the second table, it's not auto increment. I'm curious on how to
    get that unique id on the first table, set that with cfset, and then insert
    that into the id field on the second insert query.

    Any help??


    Wes

    weswhite7 Guest

  2. Similar Questions and Discussions

    1. any of you ever wrote a get_next_id function?
      function getNewID($fieldName, $tableName) { // INT "METHOD" FOR NON-AUTO-INCREMENT FIELDS global $dbConn; $sql = "SELECT MAX($fieldName) FROM...
    2. #25473 [Fbk->Opn]: Updating single row in table causing all rows in table to be updated.
      ID: 25473 User updated by: jim at bluedojo dot com Reported By: jim at bluedojo dot com -Status: Feedback +Status: ...
    3. #25473 [Opn]: Updating single row in table causing all rows in table to be updated.
      ID: 25473 User updated by: jim at bluedojo dot com Reported By: jim at bluedojo dot com Status: Open Bug Type: ...
    4. #25473 [NEW]: Updating single row in table causing all rows in table to be updated.
      From: jim at bluedojo dot com Operating system: WinXP PHP version: 4.3.3 PHP Bug Type: MySQL related Bug description: ...
    5. Could not load type VTFixup Table from assembly Invalid token in v-table fix-up table.
      We are getting this error after clearing the web.config of database infomation - even after using the wizard to re-enter the information. I could...
  3. #2

    Default Re: Getting the ID you just wrote to a table with

    <cftransaction>
    <cfquery ......... INSERT ..... </cfquery>
    <cfquery name="selqry" SELECT Max(ID) as MaxID </cfquery>
    <cfquery ......... INSERT .... Values (#selqry.MaxID#, ....) </cfquery>
    </cftransaction>
    cftransaction will both isolate your query set from other activity and also
    RollBack everything should one of the pieces fail.




    JMGibson3 Guest

  4. #3

    Default Re: Getting the ID you just wrote to a table with

    If you are using SQL Server or Access, you may also want to take a look at this link [url]http://www.houseoffusion.com/cf_lists/messages.cfm/forumid:4/threadid:34151[/url]
    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