Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2012
    Posts
    28

    Unanswered: inserting into view

    create table m(a int not null, b int)

    create view v1 as
    select b from m

    insert into v1 values (2)

    Error: Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=6037, COLNO=0" is not allowed.. SQLCODE=-407, SQLSTATE=23502, DRIVER=4.13.111

    I am using DB2 9.7 enterprise server edition, running the program on IBM data studio,Windows7.

    I would like the solution without actually creating the view with both the columns of the table, if at all its possible.

    thank you.

  2. #2
    Join Date
    Oct 2012
    Posts
    1
    This is not possible.
    Last edited by bikashsahoo17; 11-30-12 at 07:00.

  3. #3
    Join Date
    Jan 2009
    Location
    Zoetermeer, Holland
    Posts
    746
    If db2 can assign the value to column "a" itself (think identity/defaults/triggers) then is should be possible. So it is not your view-definition, but your table-definition.
    Somewhere between " too small" and " too large" lies the size that is just right.
    - Scott Hayes

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by masood313 View Post

    I would like the solution without actually creating the view with both the columns of the table, if at all its possible.
    Provide the default value for column A in the table definition.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Mar 2003
    Posts
    280
    Quote Originally Posted by masood313 View Post
    create table m(a int not null, b int)

    create view v1 as
    select b from m

    insert into v1 values (2)

    Error: Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=6037, COLNO=0" is not allowed.. SQLCODE=-407, SQLSTATE=23502, DRIVER=4.13.111

    I am using DB2 9.7 enterprise server edition, running the program on IBM data studio,Windows7.

    I would like the solution without actually creating the view with both the columns of the table, if at all its possible.

    thank you.
    If you can determine the value of a, an instead trigger on v1 may work.
    --
    Lennart

Posting Permissions

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