Which statement is true about the blocks of code?

View the Exhibit and examine the blocks of code that you plan to execute.
Which statement is true about the blocks of code?

View the Exhibit and examine the blocks of code that you plan to execute.
Which statement is true about the blocks of code?

A.
All the blocks execute successfully and the anonymous block displays
123
cant: 45
45
cnt: 45

B.
All the blocks execute successfully and the anonymous block displays
123
cut: 0
45
cart: 1

C.
The anonymous block gives an error because the function invocation in line 2 is not valid.

D.
The procedure creation gives an error because the function invocation in line 1 is not valid.



Leave a Reply 19

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


Maxim

Maxim

C, D

Functions cannot be inviked in DEFAULT or CHECK clause.

create or replace function dflt RETURN NUMBER IS
cnt NUMBER := 0;
BEGIN
cnt := cnt + 1;
RETURN 45;
end;

create or replace procedure p(i in NUMBER DEFAULT dflt() )
BEGIN
dbms_output.put_line(i);
END p;

Function created.
Warning: compiled but with compilation errors
END;
Error at line 12
ORA-00900: invalid SQL statement

Oista

Oista

it seems you missing “IS” before “BEGIN”

alex

alex

Just tried it and the result is:
PL/SQL procedure successfully completed.

1
2
3
cnt: 45
45
cnt: 45

So correct answer is A

Divyank

Divyank

A is the correct ans, i have tested this.

User

User

p( ) is 45 because it has the default value of dflt( )

Vova M

Vova M

A

create or replace function dflt RETURN NUMBER IS
cnt NUMBER := 0;
BEGIN
cnt := cnt + 1;
RETURN 45;
end;

create or replace procedure p(i in NUMBER DEFAULT dflt() ) is
BEGIN
dbms_output.put_line(i);
END p;

declare
cnt number := dflt();
begin
for j in 1 .. 3
loop
p(j);
end loop;
dbms_output.put_line(‘cnt ‘ || cnt);
p();
dbms_output.put_line(‘cnt ‘ || cnt);
end;

Andreea

Andreea

Verified : Answer A is correct

khurshid

khurshid

why “cant” ?

gelete

gelete

A

Function created.
Procedure created.
1
2
3
cnt: 45
45
cnt: 45
PL/SQL procedure successfully completed.