Which statements correctly describe the features of functions and procedures?

Which statements correctly describe the features of functions and procedures? (Choose all that
apply.)

Which statements correctly describe the features of functions and procedures? (Choose all that
apply.)

A.
A procedure can contain a return statement without a value.

B.
A function can return multiple values using a single return clause,

C.
A procedure can be executed as part of a SQL expression or as a PL/SQL statement,

D.
A function can contain zero or more parameters that are transferred from the calling
environment.

Explanation:
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/subprograms.htm(using the
return statement)



Leave a Reply 17

Your email address will not be published. Required fields are marked *


Tr

Tr

A and D

sanjit

sanjit

agree with you, A and D

Uladzimir

Uladzimir

b aslo possible when to use record type…

Thomas Kyte

Thomas Kyte

Record, collection or object type is still one complex object (or one value).

alex

alex

A and D. It’s true that B is also possible but I think they considerer a RECORD TYPE only a value.

Maxim

Maxim

I think A,B,D

B: OUT parameters in a function

martin

martin

but not using single return clause

nina

nina

B (for example pipelined table function), D

Thomas Kyte

Thomas Kyte

You are wrong.
Pipelined functions use PIPE ROW clause instead of RETURN.
And even if you return a collection, it is still one complex object (or one value).
————–
A,D are correct answers.

tika

tika

B is also TRUE. Not because records, but because of OUT parameter.

In this example there is 1 RETURN command.
If it is reached – function will return 4 values.
If it is NOT reached (exception) – function will return 0 values.

So RETURN command made possible to return 4 values.
Also, if there is no RETURN command, exception would be raised.

declare
x number := 0;
y number := 0;
z number := 0;
w number;
function test_func(a out number, b out number, c out number) return number
is
begin
a := 1;
b := 2;
c := 3;
–raise_application_error(-20000, ‘ Not important’);
return 4;
end;
begin
w := test_func(x,y,z);
dbms_output.put_line(‘x = ‘ || x);
dbms_output.put_line(‘y = ‘ || y);
dbms_output.put_line(‘z = ‘ || z);
dbms_output.put_line(‘w = ‘ || w);
exception
when others then
dbms_output.put_line(‘x E = ‘ || x);
dbms_output.put_line(‘y E = ‘ || y);
dbms_output.put_line(‘z E = ‘ || z);
dbms_output.put_line(‘w E = ‘ || w);
end;

tika

tika

But I suggest you don’t check B,

since Oracle probably thinks different:
https://docs.oracle.com/cd/B14117_01/appdev.101/b10807/08_subs.htm#i4071

In functions, a RETURN statement must contain an expression, which is evaluated when the RETURN statement is executed. The resulting VALUE is assigned to the function identifier, which acts like a variable of the type specified in the RETURN clause.

RETURN does not set OUT variable, although it makes it possible.

Thomas Kyte

Thomas Kyte

Be careful. “B” says only about RETURN clause.

SK

SK

well caught, B becomes invalid as RETURN can parse one parameter