Вы довольно близки к решению;Интересно, почему вы сами это не исправили.
Пример таблицы и данных:
SQL> create table shipment_entity
2 (id number,
3 find_balance number
4 );
Table created.
SQL> insert into shipment_entity values (1, 100);
1 row created.
SQL> insert into shipment_entity values (2, 0);
1 row created.
Функция: Я отметил, что вы сделали неправильно (строки 5, 12, 18, 22):
SQL> CREATE OR REPLACE FUNCTION find_balance (invoice_id IN INTEGER)
2 RETURN VARCHAR2
3 IS
4 c_find_balance NUMBER (5, 2);
5 balance_status VARCHAR2 (255); --> VARCHAR2, not VARCHAR
6 BEGIN
7 SELECT find_balance
8 INTO c_find_balance
9 FROM shipment_entity
10 WHERE id = invoice_id;
11
12 IF c_find_balance = 0 --> =, not ==
13 THEN
14 balance_status := 'The payment has been Completed';
15 ELSE
16 IF c_find_balance > 0
17 THEN
18 balance_status := c_find_balance || ' yet to be paid'; --> missing concatenation; wrong variable name
19 END IF;
20 END IF;
21
22 RETURN (balance_status); --> balance_status, not c_find_balance
23 END;
24 /
Function created.
Тестирование:
SQL> select find_balance(1) res1,
2 find_balance(2) res2
3 from dual;
RES1
--------------------------------------------------------------------------------
RES2
--------------------------------------------------------------------------------
100 yet to be paid
The payment has been Completed
SQL>