Run the following while logged in as the biotics_dlink user to create the function:


CREATE OR REPLACE FUNCTION COUNT_CHR (STRING VARCHAR2, CHARACTER VARCHAR2)
RETURN NUMBER
IS
NUM NUMBER;
BEGIN
SELECT length(STRING) - length(replace(STRING, CHARACTER)) INTO NUM
FROM DUAL;
RETURN NUM;
END;
.
/


Once this function is installed, you can use it so:
 SQL> SELECT COUNT_CHR('TEST STRING','T') COUNT_THE_TS FROM DUAL;

COUNT_THE_TS
------------
3

SQL> SELECT DISTINCT COUNT_CHR(R.FULL_CITATION,'&') COUNT_THE_AMPERSANDS FROM REFERENCE R;

COUNT_THE_AMPERSANDS
--------------------
0
1
2
3


SQL>