De momento tengo esto....estoy un poco verde.: si:






Os dejo el cachillo que tengo echo:
CREATE OR REPLACE FUNCTION fecha (
valor NUMBER)
RETURN VARCHAR2;
AS
any VARCHAR2(4);
BEGIN
any := TO_CHAR(valor,'yyyy');
FOR i IN 1..4 LOOP
any2 := any||SUBSTR(fecha,i,1);
END LOOP;
RETURN any2;
END fecha;
A ver si me ayudais!!!
Grácias de antemano.