Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Posts
    9

    Unanswered: Close connection between calls

    Hi

    Say that you have an application that makes a couple of calls to the same database (insert, uppdate and delete). Do I need to close the connection between every call or can I make them over the same connection?

    I know that it is possible but cloud there be an issue in doing so?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The general rule of thumb is: close connections as soon as you can.
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2007
    Posts
    9
    Yes, but if Im going to transfer say 100 rows from one table to another thats 100 connect and 100 close. It would be better if i cloud use the same connection, it would use less resources. But if in doing so it creates error of some sort than i must close it for every insert.

    Anyone?

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You could move 100 rows from 1 table to another in one command...

    Post yourQL/code
    George
    Home | Blog

  5. #5
    Join Date
    Dec 2007
    Posts
    9
    How can i do that?

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    This should have read
    Quote Originally Posted by georgev
    Post yourQL/code
    Post your SQL/code

    Basically, I reckon you're using the following
    Code:
    INSERT INTO tableName(field1, field2) VALUES (value1, value2)
    Which means you can only do one line at a time.

    There is a lovely method you can use when transferring data from one table to another which goes a little something like this:
    Code:
    INSERT INTO tableName(field1, field2)
      SELECT otherTable.field1
           , otherTable.field2
      FROM   otherTable
      <optional where clause(s) etc>
    George
    Home | Blog

  7. #7
    Join Date
    Dec 2007
    Posts
    9
    Thanks! ill try that!

Posting Permissions

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