简体   繁体   English

SQLFiddle中的Oracle用户定义函数

[英]Oracle User Defined Functions in SQLFiddle

I'm trying to play with Oracle's user defined functions and virtual columns, but my only test environment is SQL Fiddle and I'm struggling to understand what I'm doing wrong as the error message is pretty nondescript. 我正在尝试使用Oracle的用户定义函数和虚拟列,但是我唯一的测试环境是SQL Fiddle,并且我正在努力了解我在做什么错,因为错误消息非常难以描述。

ORA-06575: Package or function COUNTER is in an invalid state

I've tried various tweaks and copy-paste attempts from different sites, but can't see to get functions and sqlfiddle to play nicely together... 我已经尝试了来自不同站点的各种调整和复制粘贴尝试,但是看不到让函数和sqlfiddle一起很好地玩...

create table test (
    x number
)
//

create
  function counter()
    return number is v_result NUMBER;
    begin
        SELECT COUNT(*) INTO v_result FROM test;
        return v_result;
    end;
//

select test.*, counter() from test
//

http://sqlfiddle.com/#!4/0c001 http://sqlfiddle.com/#!4/0c001

Anyone able to make this work, or am I headed down a blind alley? 有人能胜任这项工作,还是我走上了一条小巷?

Functions that take no arguments don't have any (empty) brackets after the name 不带参数的函数名称后没有任何括号(空)

http://sqlfiddle.com/#!4/0c001/5 http://sqlfiddle.com/#!4/0c001/5

You can query the sys.user_errors table for a list of the compilation errors. 您可以查询sys.user_errors表以获取编译错误列表。 "Invalid state" means the code didn't compile “无效状态”表示代码未编译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM