Forum Stats

  • 3,853,608 Users
  • 2,264,246 Discussions
  • 7,905,416 Comments

Discussions

Handler parameter type BOOLEAN not supported

PeeZu
PeeZu Member Posts: 27 Blue Ribbon

Hello,

When I try to define an module handler parameter type in BOOLEAN, the HTTP 500 occur with the error: java.lang.IllegalArgumentException: java.lang.Boolean is not supported

Version: ORDS 3.0.4

It is supported or not ?

Answers

  • Kiran Pawar
    Kiran Pawar Member Posts: 2,951 Bronze Crown
    edited Apr 5, 2016 5:06AM

    Hi PeeZu,

    PeeZu wrote:
    
    When I try to define an module handler parameter type in BOOLEAN, the HTTP 500 occur with the error: java.lang.IllegalArgumentException: java.lang.Boolean is not supported
    Version: ORDS 3.0.4
    It is supported or not ?
    
    

         The ORDS 3.0 documentation says the parameter type of BOOLEAN is supported.

         Refer: https://docs.oracle.com/cd/E56351_01/doc.30/e56293/ords_ref.htm#sthref120 (See the p_param_type description in ORDS.DEFINE_PARAMETER)

    Regards,

    Kiran

  • Kris Rice-Oracle
    Kris Rice-Oracle Posts: 1,393 Employee
    edited Apr 7, 2016 1:09PM

    Keep in mind using ORDS.DEFINE_PARAMETER is part of ORDS 3.x.  This means using either SQL Developer or the PL/SQL APIs directly and not using the screens inside APEX

  • PeeZu
    PeeZu Member Posts: 27 Blue Ribbon
    edited Apr 8, 2016 7:06AM

    Hi Kris,

    I use ORDS 3.0.4 and parameter is define by the PL/SQL API, try out the following example:

    DECLARE
    
      l_module       VARCHAR2(100);
      l_resource     VARCHAR2(100);
    
    BEGIN
    
      l_module := 'module';
    
      -- delete all REST services and disable REST services for this schema
      ords.drop_rest_for_schema();
    
      -- enable REST for this schema
      ords.enable_schema();
    
      -------------------------------------------------------------------------------------------------
    
      -- define module
      ords.define_module(p_module_name    => l_module,
                         p_base_path      => '/',
                         p_items_per_page => 0,
                         p_status         => 'PUBLISHED',
                         p_comments       => NULL);
    
      -------------------------------------------------------------------------------------------------
      l_resource := 'boolean/';
    
      -- define resource template    
      ords.define_template(p_module_name => l_module,
                           p_pattern     => l_resource,
                           p_priority    => 0,
                           p_etag_type   => 'NONE',
                           p_etag_query  => NULL,
                           p_comments    => NULL);
    
      -- define resource handler
      ords.define_handler(p_module_name    => l_module,
                          p_pattern        => l_resource,
                          p_method         => 'GET',
                          p_source_type    => ords.source_type_plsql,
                          p_source         => q'[BEGIN
                                                   :boolean := true;
                                                 END;]',
                          p_items_per_page => 0,
                          p_mimes_allowed  => NULL,
                          p_comments       => NULL);
    
    -- define resource handler parameter
      ords.define_parameter(p_module_name        => l_module,
                            p_pattern            => l_resource,
                            p_method             => 'GET',
                            p_name               => 'foo',
                            p_bind_variable_name => 'boolean',
                            p_source_type        => 'RESPONSE',
                            p_param_type         => 'BOOLEAN',
                            p_access_method      => 'OUT',
                            p_comments           => NULL);
    
      COMMIT;
    
    END;
    /
    

    My result is always: InternalServerException [statusCode=500, reasons=[An unexpected error with the following message occurred: java.lang.Boolean is not supported]]

    What's wrong with my declaration ?

    Regards

  • Kris Rice-Oracle
    Kris Rice-Oracle Posts: 1,393 Employee
    edited Apr 8, 2016 9:42AM

    I wish all question came with complete test cases !

    There is indeed a bug here.  We'll get it fixed as soon as we can.  In the meantime, you'll have to do a boolean to varchar.  There is a nice/easy helper to do this for you

    Change your source to this:

         :boo := sys.diutil.bool_to_int(TRUE);

    Then the OUT param to string

                            p_param_type         => 'STRING',

    -kris

  • PeeZu
    PeeZu Member Posts: 27 Blue Ribbon
    edited Apr 8, 2016 10:14AM

    Thanks for the response.

    Of course casting to string resolve this issue, but JSON response won't be as boolean:

    Expected: {"foo":true}

    Got: {"foo":"1"}

    I'll wait for the fix.

    Regards.

This discussion has been closed.