当尝试创建Oracle SQL Java函数生成随机UUID时
in this StackOverflow answer
,我得到以下错误:
sql> CREATE or REPLACE FUNCTION random_uuid
RETURN VARCHAR2
AS LANGUAGE JAVA NAME 'java.util.UUID.randomUUID() return java.lang.String'
[2019-01-29 09:28:29] [99999][17110] Warning: execution completed with warning
[2019-01-29 09:28:29] completed in 23 ms
[2019-01-29 09:28:29] 3:78:PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
[2019-01-29 09:28:29] ;
[2019-01-29 09:28:29] The symbol ";" was substituted for "end-of-file" to continue.
即使这只是一个警告,称之为“警告”之后也不起作用:
sql> select random_uuid() from dual
[2019-01-29 09:36:28] [65000][6575] ORA-06575: Package or function RANDOM_UUID is in an invalid state
我使用IntellijIDEA的数据库控制台来执行脚本。怎么了?
编辑:
我的原始脚本末尾不包含分号:
create or replace function random_uuid return varchar2 as
language java
name 'java.util.UUID.randomUUID() return String';
在后面添加“;”
弦
无济于事:
create or replace function random_uuid return varchar2 as
language java
name 'java.util.UUID.randomUUID() return String;';