如何使用作为查询的值的start开始创建序列

时间:2013-08-28 18:23:17

标签: sql oracle sequence

我在Create a Sequence with START WITH from Query看到了同样的问题,但它不起作用。它有12票,所以我不确定为什么它不适合我。

这就是我所拥有的:

declare
    l_new_seq INTEGER;
begin
   select max(expense_detailid) + 1
   into   l_new_seq
   from   expense_detail;

   execute immediate 'create sequence expense_detail_seq 
                      start with ' || l_new_seq || ' increment by 1';
end;
/

这是我得到的错误:

ORA-06550: line 3, column 17:
PLS-00103: Encountered the symbol "create sequence expense_detail_seq start with " when expecting one of the following:

   := . ( @ % ;
The symbol ":=" was substituted for "create sequence expense_detail_seq start with " to continue. (DBD ERROR: error possibly near <*> indicator at char 27 in '
    BEGIN
      immediate <*>'create sequence expense_detail_seq start with ' || l_new_seq || ' increment by 1';
    END;
  ')

ORA-00900: invalid SQL statement

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:1)

将所有文字放在一行中。或至少每个文字。

此外,产品/实用程序和产品版本是什么?