Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    43

    Unanswered: constraints and transactions

    that I want to do :
    Code:
    update command options using c off;
    create table ttt(id integer not null);
    commit;
    insert into ttt values(null)
    <....>
    update ttt set id = 1;
    commit
    but DB2 check "not null" constraint inside transaction. But I want to check it after transaction..
    how can I do it?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Create the table without the unique constraint; add the constraint when you're finished with updates.

  3. #3
    Join Date
    Dec 2004
    Posts
    43
    Quote Originally Posted by n_i
    Create the table without the unique constraint; add the constraint when you're finished with updates.
    I want to use such transactions at any time - not only after table creation

  4. #4
    Join Date
    Jul 2005
    Posts
    25
    You can switch a constraint to enforced or not enforced state...
    for instance:

    update command options using c off;
    create table ttt
    (id integer
    constraint chk_null CHECK(id is not null)
    );
    commit;
    alter table ttt alter CHECK chk_null not enforced;
    insert into ttt values(null);
    <....>
    update ttt set id = 1;
    alter table ttt alter CHECK chk_null enforced;
    commit;

Posting Permissions

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