DJ180
DJ180

Reputation: 19854

Oracle: Possible to return nothing from PL/SQL function?

As the title says, is it possible to return nothing from a PL/SQL function?

My function is as follows, and I am getting errors when I leave out the return:

create or replace
FUNCTION DeleteAttributes
(code IN varchar2)
CURSOR c_attributes = SELECT ...

BEGIN
    FOR attribute_record IN c_attributes
    LOOP
        ...
    END LOOP;
END;

Upvotes: 11

Views: 51540

Answers (2)

DCookie
DCookie

Reputation: 43533

By definition, a function returns a value, so you must have a RETURN statement. Have a look at the syntax definition for a function in the Oracle documentation. RETURN is not an option.

I'm not even sure why you would want to do this.

Upvotes: 4

Oracle PL/SQL functions must have a return. If you declare your subprogram as a procedure, then it won't give you errors when it is lacking a return (procedures can't have a return).

create or replace
PROCEDURE DeleteAttributes
(code IN varchar2)
CURSOR c_attributes = SELECT ...

BEGIN
    FOR attribute_record IN c_attributes
    LOOP
        ...
    END LOOP;
END;

Upvotes: 19

Related Questions