How can I insert multiple rows into oracle with a sequence value?

前端 未结 6 688
孤独总比滥情好
孤独总比滥情好 2020-12-13 03:58

I know that I can insert multiple rows using a single statement, if I use the syntax in this answer.

However, one of the values I am inserting is taken from a seque

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 04:17

    From Oracle Wiki, error 02287 is

    An ORA-02287 occurs when you use a sequence where it is not allowed.

    Of the places where sequences can't be used, you seem to be trying:

    In a sub-query

    So it seems you can't do multiples in the same statement.

    The solution they offer is:

    If you want the sequence value to be inserted into the column for every row created, then create a before insert trigger and fetch the sequence value in the trigger and assign it to the column

提交回复
热议问题