-1

Often times, I ran into constraint violation while using insert statements.

For ex.

INSERT INTO table_1 (col1, col2, ..., col100) 
VALUES (val1, val2, ..., val100);

Now, is there a fast way of navigating to the 34th column's value by making this insert statement into more readable form like key-value pairs?

Any help is this regard is much appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Chaipau
  • 199
  • 1
  • 5
  • 14
  • 1
    Give the constraints meaningful names. – jarlh Jan 15 '18 at 12:49
  • Ok, added a constraint name, but my question pertains to identifying the For ex. value for 56th column from the insert statement in a fast way, instead of manually navigating to that value. – Chaipau Jan 15 '18 at 12:54
  • 1
    Format the code using TOAD and in the editor, enable line numbers. – Kaushik Nayak Jan 15 '18 at 12:57
  • 3
    Not everyone uses TOAD (read: it is expensive). Though, there are free SQL formatters online, such as http://www.dpriver.com/pp/sqlformat.htm . But yes, I agree with the general idea - format it nicely and it'll be much more obvious what's going on. – Littlefoot Jan 15 '18 at 13:00
  • 1
    There is `INSERT SELECT`, `INSERT VALUES` and `MERGE`. None of them has a key-value pair syntax. I suppose you could write a procedure and call it using named parameters. Otherwise I am not sure what you are asking. – William Robertson Jan 15 '18 at 15:52

1 Answers1

0

This is due to foreign key value has no matching primary key value. you are adding primary key in this insert which is not the part of Primary key of any table.

First Add Primary Key, then Insert this statement.

  • Yes, I am not interested in the particular of why this insert failed, but just a method of navigating to suppose the 56th value in the values list, instead of manually navigating to it. – Chaipau Jan 15 '18 at 12:56
  • Check this hope it help you to find the nth column http://burnignorance.com/database-tips-and-tricks/fetch-nth-column-of-a-table/ – Muhammad Imran khan Jan 15 '18 at 12:57