当插入值需要从另外一张表中检索得到的时候,如下语法的sql语句已经不能完成该功能:
insert into my_table(id, name) value ((select seq_my_table.nextval from dual), ‘runto30’);
会报“ORA-02287: sequence number not allowed here”的错误,可以使用如下语句来完成:
insert into my_table(id, name) select seq_my_table.nextvalue, ‘runto30’ from dual;
参考:http://www.dbforums.com/printthread.php?t=380997
Post a comment now »
本文目前不可评论
Sorry, the comment form is closed at this time.
No comments yet.