Oracle 18c introduces Qualified Expressions:
Qualified expressions improve program clarity and developer productivity by providing the ability to declare and define a complex value in a compact form where the value is needed.
A qualified expression combines expression elements to create values of a RECORD type or associative array type.
Qualified expressions use an explicit type indication to provide the type of the qualified item.
DECLARE
TYPE MyType IS TABLE OF VARCHAR2(10) INDEX BY VARCHAR2(10);
FUNCTION TestFunction(Input IN MyType) RETURN NUMBER
IS
BEGIN
RETURN Input.Count;
END;
BEGIN
DBMS_OUTPUT.put_line(TestFunction(MyType('Ind1' => 1, 'Ind2' => 2)));
END;
/
-- output:
-- 2
Creating type(varray) and direct SELECT from collection:
CREATE OR REPLACE TYPE MyType is varray(10) of integer;
/
SELECT *
FROM MyType(1,2,3);
-- Output:
COLUMN_VALUE
===========
1
2
3
Or as default parameter to function:
CREATE OR REPLACE FUNCTION MyFunc(Input IN MyType DEFAULT MyType(1,2,3))
RETURN NUMBER
IS
BEGIN
RETURN Input.Count;
END;
/
SELECT MyFunc FROM dual;
-- Output:
MYFUNC
======
3
db<>fiddle demo