mulitple query insert problem

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

  1. #1

    Default Re: mulitple query insert problem

    Ben.

    I am doing the scenario where the id key is auto generated from Access. I
    know I need to get that id to do the second insert into the related table, but
    I don't know how to retrieve that id. Could I do some sort of retrieve the
    last record added?

    thanks

    dtubbs Guest

  2. Similar Questions and Discussions

    1. Dynamic insert query problem.
      Why is not working? Thanks. <cffunction name="InsertRow" hint="Insert a row in the table" access="remote" returnType="query" > <cfargument...
    2. How do I Query mulitple datasources?
      Here is what I have and what I need to do... 1. I have multiple dabases with financial transactions. All are based on the same table structure. ...
    3. Mulitple recordset speed problem.
      Hi! I hav e solution thar loops one recordset and in the loop opens an other. All off a sudden it is getting reeeeeeeeel slooooooow. On one server!...
    4. Mulitple Table Query Help
      I'm not sure the follow multiple table query is the right way to do what I need to do although it seems to be working: $php_SQL = "SELECT * "....
    5. SQL Insert Query using ADO
      Hi, I am sending an SQL Insert query to my ADO connection object, my Insert query looks a litte like this... INSERT INTO tblRequests...
  3. #2

    Default Re: mulitple query insert problem

    Like Ben said, put a SELECT statement between the first and second INSERTs:
    <cfquery name='getPK' ... SELECT MAX(id) as newpk from TheFirstTable </cfquery>
    and then use getPK.newpk as the value to use as the foreign key in the second
    INSERT.

    philh Guest

  4. #3

    Default Re: mulitple query insert problem

    Thanks

    that did the trick

    dtubbs 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