Finding the Record-no after CFINSERT

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

  1. #1

    Default Finding the Record-no after CFINSERT

    I've created a vehicle maintence cf database. On the new record page the user
    enters the service details and then picks parts from a like that have been
    replaced. When the submit button is pressed the action page creates a new
    record in the MaintenceRecord table and then needs to know the record number
    which will be added to each part record insertes into the PartsReplaced table.
    On creating the primary key record in the MaintenceRecord table how do I read
    it for use in the ReplacedParts table. Can the CFINSERT command return the
    value. If I have to do a database QUERY other record may have been created
    since my record was created and I'm worried I will not receive the correc value
    and the ReplacedParts may appear againce another record.

    Any help would be much appreciated.

    Graham Brown

    gbrownuk Guest

  2. Similar Questions and Discussions

    1. cfinsert help
      I would like to have people insert information into a database. It's a single table in a database, so I thought I would try <cfinsert> I'm...
    2. cfinsert from javascript
      I have write javascript to create form field when button is click. function addEvent(myTable){ var lastRow = myTable.rows.length; var...
    3. Finding the most recent record in a table with otherwiseidentical field values
      Hello, Would anyone be able to share how they find the MOST recent record among otherwise identical records in for example a transaction table?
    4. CFInsert
      Hi. I was hoping I could get help on an issue. I am using CFInsert to add data from a form into two tables that are related. Table 1: Members...
    5. finding first unread record
      I am looking for a simple way to query a table and pull up the first record with an empty value in the date_processed column. I have tried a...
  3. #2

    Default Re: Finding the Record-no after CFINSERT

    <cftransaction>
    <cfinsert>
    <cfquery name="getId">
    Select Max(ID) As MaxId
    From myTable
    </cfquery>
    </cftransaction>

    The cftransaction ensures that both actions are performed together.
    But if your using ms access 2k or above or ms sql you can use
    <cftransaction>
    <cfinsert>
    <cfquery name="getId">
    Select @@Identity As MaxId
    From myTable
    </cfquery>
    </cftransaction>

    Ken

    The ScareCrow Guest

  4. #3

    Default Re: Finding the Record-no after CFINSERT

    That's great, I can use that. Thankyou

    Graham
    gbrownuk 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