problem with 2 not null fileds on one table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suresh Chowdary
    New Member
    • Nov 2006
    • 9

    problem with 2 not null fileds on one table

    Hi everyone,

    i ahve the one table with 2 not null fileds ,in this one column accept certain values (1,2,3), and another column will accept (1m,2m,3m).

    the problem is when the data extracting from differnt sources we have 2 types of sources.
    if suppose first source is extracting data into table the y will populate their repective filed ,they will not populate another filed. in that time not null constraint voilation is coming..

    can u provide aany solution for this....friends ..
  • pragatiswain
    Recognized Expert New Member
    • Nov 2006
    • 96

    #2
    example

    While inserting, in anycase you are providing NULL value for the NOT NULL column, this error occurs. Alter the table to set default value for the column.

    ALTER TABLE <TABLE-NAME> MODIFY <COLUMN-NAME> DEFAULT <DEFAULT-VALUE>

    example : ALTER TABLE TABLE_X MODIFY COLUMN_Y DEFAULT '1m'

    Hope this helps
    Last edited by pragatiswain; Nov 17 '06, 11:15 AM. Reason: example

    Comment

    • suresh Chowdary
      New Member
      • Nov 2006
      • 9

      #3
      [QUOTE=pragatisw ain]While inserting, in anycase you are providing NULL value for the NOT NULL column, this error occurs. Alter the table to set default value for the column.

      ALTER TABLE <TABLE-NAME> MODIFY <COLUMN-NAME> DEFAULT <DEFAULT-VALUE>

      example : ALTER TABLE TABLE_X MODIFY COLUMN_Y DEFAULT '1m'

      Hope this helps[/QUOT


      Thanks for ur help. friend

      Comment

      • pragatiswain
        Recognized Expert New Member
        • Nov 2006
        • 96

        #4
        You set default value for both the columns of the same table.

        ALTER TABLE TABLE_X MODIFY COLUMN_Y DEFAULT '1m'
        ALTER TABLE TABLE_X MODIFY COLUMN_Z DEFAULT 1

        Comment

        Working...