Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2007
    Posts
    1

    Unanswered: How to execute morethan one insert statement in single shot?

    hi,
    Can anyone tell me, that how to execute morethan one INSERT query in a single shot?

    I mean to ask that, i want to execute two INSERT statement, currently im doing that one as follow;

    db.commandstring = "INSERT statement 1";
    db.ExecuteNonQuery();

    db.commandstring = "INSERT statement 2";
    db.ExecuteNonQuery();

    But now i want to execute the both statement under single ExecuteNonQuery();

    Is there any chance to do like that? Can i concatenate Both INSERT statement in Single "CommandString" and execute ( db.commandString="INSERT statement1; INSERT statement2"; db.ExecuteNonQuery());

    Give me a suggestion plz.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Your 'db.ExecuteNonQuery()' stuff is unknown to me; also, you didn't mention your Oracle database version. So, if it is supported, you might try to use INSERT ALL, like in the following example:
    Code:
    SQL> create table test (id number, name varchar2(20));
    
    Table created.
    
    SQL> insert all
      2    into test values (1, 'Little')
      3    into test values (2, 'Foot')
      4    into test values (3, 'Someone')
      5    into test values (4, 'Else')
      6  select * from dual;
    
    4 rows created.
    
    SQL> select * From test;
    
            ID NAME
    ---------- --------------------
             1 Little
             2 Foot
             3 Someone
             4 Else
    
    SQL>

Posting Permissions

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