3 Replies Latest reply on Nov 7, 2018 10:19 PM by Olafur T

    Migrating from mod_owa, checkbox input or owa_util.ident_arr value type

    Olafur T

      Hi,

       

      working with ORDS 18.3 and tomcat 8. Trying to call a procedure that takes in owa_util.ident_arr that used to receive the values from a form checkboxes.

       

      What's the best way to deal with a POST handler that submits checkbox values? ORDS does not convert it into JSON so any attempt to parse it will give it an error of  "ORA-20987: Error at line 1, col 1: strict mode JSON parser does not allow unquoted literals"

      So, the body is kept as plain "form data" and not parsed.

       

      Printing the body will show a traditional form body like "param1=val1&param2=val2&chk1=chkval1&chk1=chkval2&chk1=chkval3&chk1=chkval4"

       

      So what is the "correct" way to parse checkbox array value of "chk1" without doing extensive string manipulations?

       

      I've tried a few ways to get it in but all results in an ORDS 500 error.

       

      Is my only way to use "apex_string.split("parsed body", '\s*[=&]\s*');" and loop over all "chk1" and add them to an array?

       

      Thanks in advance

      Olafur

        • 1. Re: Migrating from mod_owa, checkbox input or owa_util.ident_arr value type
          Pierre Yotti

          Olafur wrote:

           

          Hi,

           

          working with ORDS 18.3 and tomcat 8. Trying to call a procedure that takes in owa_util.ident_arr that used to receive the values from a form checkboxes.

           

          What's the best way to deal with a POST handler that submits checkbox values? ORDS does not convert it into JSON so any attempt to parse it will give it an error of  "ORA-20987: Error at line 1, col 1: strict mode JSON parser does not allow unquoted literals"

          So, the body is kept as plain "form data" and not parsed.

           

          Printing the body will show a traditional form body like "param1=val1&param2=val2&chk1=chkval1&chk1=chkval2&chk1=chkval3&chk1=chkval4"

           

          So what is the "correct" way to parse checkbox array value of "chk1" without doing extensive string manipulations?

           

          I've tried a few ways to get it in but all results in an ORDS 500 error.

           

          Is my only way to use "apex_string.split("parsed body", '\s*[=&]\s*');" and loop over all "chk1" and add them to an array?

           

           

          That is a example that Kris share to us. you should try to get each value using the bind variable name like :param1, :param2 etc

           

          Bildschirmfoto 2018-11-07 um 23.08.35.png

          • 2. Re: Migrating from mod_owa, checkbox input or owa_util.ident_arr value type
            Olafur T

            Hey,

             

            So this is my workaround, this takes the form values cast to an array to work with (calling :chk1 will only give the first selected option). This works fine and doesn't seem to have any serious overhead.

              function array_from_form(p_arr in apex_t_varchar2, p_key in varchar2) return apex_t_varchar2 is
                l_ret     apex_t_varchar2 := apex_t_varchar2();
                l_usenext boolean := false;
                l_isval   boolean := false;
              begin
                for i in 1 .. p_arr.count loop
                      
                  if l_usenext = true and l_isval = true then
                    l_ret.extend;
                    l_ret(l_ret.count) := p_arr(i);
                    l_usenext := false;
                  end if;
                
                  if p_arr(i) = p_key and l_isval = false then
                    l_usenext := true;
                  end if;
                
                  l_isval := not (l_isval);
                end loop;
              
                return l_ret;
              end;
            

             

            I can call it like

            declare
              l_arr apex_t_varchar2;
              l_chk apex_t_varchar2;
            begin
              l_arr := apex_string.split(l_body, '\s*[=&]\s*');
              l_chk := array_from_form(l_arr, 'chk1');
            end;
            

             

            the array "l_chk" will have all the selected values. Trying to make sure the function doesn't fuddle up if for some reason there is a value with the same name as the key.

             

            Seems to work fine, at least

             

            Olafur,

            • 3. Re: Migrating from mod_owa, checkbox input or owa_util.ident_arr value type
              Olafur T

              Hi,

               

              Thanks, but I know how I "should" work with ORDS. I'm trying to minimize work migrating procedures already in production that work with mod_owa and not with ORDS.

               

              Regards

              Olafur