SQL CREATE OR REPLACE FUNCTION REGID17 2 3 LEDGERVIEW DDILED

SQL> CREATE OR REPLACE FUNCTION REGID17
2
3 LEDGERVIEW DDI.LEDGER_VIEW%TYPE;
4 BEGIN
5 SELECT LEDGER_VIEW INTO LEDGERVIEW FROM DDI WHERE REGID IS NOT NULL;
6 dbms_output.put_line(\'Ledger View = \' ||LEDGERVIEW );
7 END;
8 /

Warning: Function created with compilation errors.

How do I make this code run without a error message?

Solution

Here before END you have to return the value of LEDGERVIEW.

as function always returns a value,

so your code will be like this,

CREATE OR REPLACE FUNCTION REGID17
  
LEDGERVIEW DDI.LEDGER_VIEW%TYPE;
BEGIN
SELECT LEDGER_VIEW INTO LEDGERVIEW FROM DDI WHERE REGID IS NOT NULL;
dbms_output.put_line(\'Ledger View = \' ||LEDGERVIEW );
return LEDGERVIEW;
END;
/

now you can run the above code.

SQL> CREATE OR REPLACE FUNCTION REGID17 2 3 LEDGERVIEW DDI.LEDGER_VIEW%TYPE; 4 BEGIN 5 SELECT LEDGER_VIEW INTO LEDGERVIEW FROM DDI WHERE REGID IS NOT NULL; 6

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site