+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16

Thread: INSERT in 2 different tables?

  1. #11
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by richyrich View Post
    I think the best thing to do is work out why the query is returning more than 1 record as that's the only reason I can see why you'd get 5 inserts.

    Even if you kept the loop, it would only loop through 1 record then.

    Are my presumptions on the performance correct? Should it only be 1 record?
    I have put in DISTINCT in the sql statement.. so it should only show up 1 record rite?

    the query is supposed to only show up 1 record, you are rite.

    but when i de-bug i get this showing up:
    Code:
    INSERT INTO bookings (performanceID, customerID, bookingDate) VALUES ('3','1','23/11/2009');INSERT INTO performances(Status) VALUES('Booked');0No update permissions!
    

  2. #12
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Rich, the line of code you suggested:

    sql=sql & "INSERT INTO performances(Status) VALUES('Booked');"

    How does it know which performance it should set as Booked...

    hmmmmmmm think we need the performanceID rite?

  3. #13
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Centurion View Post
    Rich, the line of code you suggested:

    sql=sql & "INSERT INTO performances(Status) VALUES('Booked');"

    How does it know which performance it should set as Booked...

    hmmmmmmm think we need the performanceID rite?
    No idea, I'm afraid. Was just going by your original post
    Quote Originally Posted by Centurion
    insert "Booked" into the performances table, column name - Status
    I notice you also have On Error Resume Next in your code. That will suppress any errors you're having with your code.

  4. #14
    Contracted Slave Centurion is on a distinguished road Centurion's Avatar
    Join Date
    Dec 2008
    Posts
    533
    Rep Power
    4

    Quote Originally Posted by richyrich View Post
    No idea, I'm afraid. Was just going by your original post

    I notice you also have On Error Resume Next in your code. That will suppress any errors you're having with your code.
    im such a wally.. have been talking about Insert statements when i really want to "Update" the status based on performanceID


  5. #15
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Gotcha...I'd probably change the INSERT statement into an UPDATE statement then...

  6. #16
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    2,386
    Blog Entries
    5
    Real Name
    Wolff
    Rep Power
    15

    This should be in a Stored Procedure and run as a Transaction. Consider the problem if the first INSERT fails -- do you want to do the second? What if the second fails -- do you want to rollback the changes made from the first?

    Also, I too see no way that these INSERT statement could ever insert more than a single record into the table.
    Wolffy
    .-- ----- ..-. ..-. -.--
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Void where prohibited by law. Not valid in California. Your mileage may vary.

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Simple Insert Page Help?
    By Centurion in forum ASP Development
    Replies: 7
    Last Post: October 20th, 2009, 10:51 AM
  2. Bulk Insert with other requirements..
    By yangski in forum Microsoft SQL Server
    Replies: 2
    Last Post: August 12th, 2009, 08:55 PM
  3. How to insert variable html into php
    By evdv in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2009, 08:54 PM
  4. Help with handling sql insert error
    By Rebelle in forum ASP Development
    Replies: 11
    Last Post: August 29th, 2008, 02:20 PM
  5. can not insert duplicate key
    By guddu in forum Microsoft SQL Server
    Replies: 1
    Last Post: August 20th, 2008, 10:27 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO