CREATE OR REPLACE FUNCTION Q_TO_NUMBER(S IN VARCHAR2) 
RETURN NUMBER
IS
Result NUMBER(10);
BEGIN
  Result := 0;
  IF S IS NOT NULL THEN
    Result := TO_NUMBER(S);
  END IF;
  RETURN Result;
EXCEPTION
  WHEN OTHERS THEN RETURN -1;
END;
/
