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.
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...
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
Anyone able to make this work, or am I headed down a blind alley?