Results 1 to 6 of 6

Thread: transactions

  1. #1
    Join Date
    Dec 2004
    Posts
    43

    Unanswered: transactions

    how can i start transaction?
    before DB2 I have using PostgresSQL and i just do
    Code:
    CREATE table t111(id integer);
    START TRANSACTION ;
    insert into t111 values(1);
    insert into t111 values(2);
    insert into t111 values(3);
    select count(*) from t111;
     count
    -------
         3
    (1 row)
    
    rollback;
    select count(*) from t111;
     count
    -------
         0
    (1 row)
    in db2 i do
    Code:
    CREATE table t111(id integer)
    commit
    insert into t111 values(1)
    insert into t111 values(2)
    insert into t111 values(3)
    select count(*) from t111
    
    1
    -----------
              3
    rollback
    select count(*) from t111
    
    1
    -----------
              3
    that I must to do to get real transaction?
    PS sorry for my english

  2. #2
    Join Date
    Nov 2004
    Posts
    374

    autocommit

    if executed from command line
    put all statements in a file
    execute with db2 -tv +c -f filename
    or see db2 ? options or see Command line processor options in infocenter
    Best Regards, Guy Przytula
    DB2/ORA/SQL Services
    DB2 DBA & Advanced DBA Certified
    DB2 Dprop Certified
    http://users.skynet.be/przytula/dbss.html

  3. #3
    Join Date
    Apr 2005
    Posts
    41
    There isn't an explicit TRANSACTION in DB2, but there is:

    db2 "create table g1 (col1 int)"
    db2 "insert into g1 values(1)"
    db2 "commit"
    db2 +c "insert into g1 values(2)"
    db2 "rollback"

    in the above scenario, onlt the value of 1 will be in the table

    Within SQL/PL in DB2 Stored Procedures, you can make use
    of the SAVEPOINT, COMMIT, ROLLBACK commands.

    Graham Martin
    http://www.ibm.com/software/data/db2/migration/

  4. #4
    Join Date
    Apr 2004
    Posts
    54
    By default db2 uses autocommit.
    You can use "update command options" to disable autocommit.

    --disable autocommit
    update command options using c off
    .
    .
    .
    commit
    -- enable autocommit
    update command options using c on

  5. #5
    Join Date
    Dec 2004
    Posts
    43
    Quote Originally Posted by gardenman
    By default db2 uses autocommit.
    You can use "update command options" to disable autocommit.

    --disable autocommit
    update command options using c off
    .
    .
    .
    commit
    -- enable autocommit
    update command options using c on
    thnx..
    but I'm using DB2 via ODBC..
    How can I do smth like this via ODBC?
    I want to use some statements with autocommit and another statements without it (with manual commit/rollback)

  6. #6
    Join Date
    Dec 2004
    Posts
    43
    Quote Originally Posted by nelapsi
    thnx..
    but I'm using DB2 via ODBC..
    How can I do smth like this via ODBC?
    I want to use some statements with autocommit and another statements without it (with manual commit/rollback)
    thnx to all..
    I did it via odbc

Posting Permissions

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