oracle-databaserestplsqloracle-apexoracle-ords

An unexpected error with the following message occurred: For input string: ""


I'm getting the following error from ORDS when an AJAX process is executed within a page in APEX:

An unexpected error with the following message occurred: For input string: ""

The code I was using for printing the response to the HTTP stream was:

DECLARE
    L_HTTP_STATUS NUMBER;
    L_HTTP_REASON_PHRASE VARCHAR2(32767);
BEGIN
    -- ...
    APEX_JSON.INITIALIZE_OUTPUT(
        P_HTTP_HEADER => FALSE,
        P_INDENT => 4
    );
    OWA_UTIL.MIME_HEADER(
        CCONTENT_TYPE => 'application/json',
        BCLOSE_HEADER => FALSE,
        CCHARSET => NULL
    );
    OWA_UTIL.STATUS_LINE(
        NSTATUS => L_HTTP_STATUS,
        CREASON => L_HTTP_REASON_PHRASE,
        BCLOSE_HEADER => TRUE
    );
    APEX_JSON.OPEN_OBJECT();
    -- ...
    APEX_JSON.CLOSE_OBJECT();
END;

Although nothing seems wrong with it I'm still getting the error.


Solution

  • Turns out the error was that the L_HTTP_STATUS variable was never being set, therefore was NULL, and ORDS doesn't like NULL status headers, although I wonder why is it that OWA_UTIL.STATUS_LINE allows NULL in the first place. Anyway hopefully it helps someone who is having the same error.