2

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?

2
  • Whomever voted to close, please could you comment on your rational? Commented Dec 2, 2017 at 14:11
  • I didn't understand it either. Could say it was more of an irrationale :) Commented Dec 2, 2017 at 20:45

1 Answer 1

3

Functions that take no arguments don't have any (empty) brackets after the name

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

You can query the sys.user_errors table for a list of the compilation errors. "Invalid state" means the code didn't compile

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.