4 Replies Latest reply on Feb 4, 2013 9:45 PM by John K.-Oracle

    Yet another 'checkbox in Tabular Form' question

    John K.-Oracle
      Hi Everyone - I feel like this topic has been beat to death but I'm not super techie and it's very difficult for me to decipher the myriad solutions that have been offered in this forum.

      I downloaded and installed the simple checkbox plugin. I want to use this to allow the user to select a checkbox which should then update a varchar2(1) column in my database table with either a 'Y' or 'N' depending on if the checkbox is checked. In a simple APEX form this works easily and with no issues as I can select the Simple Checkbox plugin from the 'display as' dropdown for a given item when creating the form.

      In a Tabular Form there is no option to select the simple checkbox plugin for the 'display as'. So can I assume that this is not supported and therefore I need to use the apex_item.checkbox function in my select statement?

      I did try this and I see a checkbox rendered on my Tabular Form, but when I select the checkbox for a given row and click update I get this error:
      'Current version of data in database has changed since user initiated update process. current row version identifier = "9660AA52272606105296577232D033C7" application row version identifier = "AC661FC2F31800615ABE16CA014BB96F" (Row 1)'
      I looked at Denes' example here > http://deneskubicek.blogspot.com/2008/10/tabular-form-checkbox-for-setting.html, but I just can't believe that this much code is required to do something so simple.

      I have a sample app setup at http://apex.oracle.com where I reproduced my setup:
      Workspace: Leppard
      username/pw: guest/app_1000
      MyTestApp > MyTabularForm.
      The column in question is 'Checkbox' and the db column in Emp is also named chechbox.
      Any suggestions would be much appreciated.

        • 1. Re: Yet another 'checkbox in Tabular Form' question
          Joni Vandenberghe
          Hi john,

          Thanks for creating an example, this has sure made this easier :-)

          The error you are getting is because your column name is different from the column name in your query.

          I changed your query to this (checkbox to "CHECKBOX")
          from "#OWNER#"."EMP"
          Your checkbox also had no LOV definition so I wrote "Y,N" there

          It seems to work now.
          • 2. Re: Yet another 'checkbox in Tabular Form' question
            Tom Petrus
            Hi John,

            If you would want to implement an ajax call which updates a given record when you change the checkbox, that is easy enough. However, implementing it in the way that your example is set up will indeed lead to the problem you are encountering and for a good reason.
            When the page is rendered a checksum is generated for each of your rows based on the current values in the database. When the page is submitted and it gets to the multi-row-update process, apex will again make a checksum of the current values in the database and compare this to the checksum of the submitted rows (which is still the checksum that was generated at the time of rendering). If these do not match it indicates the record has been changed between render and submit, and a submit is not possible because of that. This is the implementation of apex to prevent lost updates.
            This means that when you implement an on-the-fly update of a value of a record in a tabular form (=altering the value in the database) and then submitting the form, this 'current version...' error will popup, because that is exactly what happened.

            Your example application had the checkbox column in the sql. You then made a checkbox out of it with apex_item, and continued to set the display as "Simple Checkbox". Unnecessary: include the checkbox in the select and set the display as "Simple Checkbox", and provide the values in the "List of values definition" (Y,N). This will handle the checkbox values in your tabular form the standard way.
            This still will not allow you to do changes to the value using ajax and then submit the rows. It will not break submitting however.

            If all that you want to do is to change the value of a checkbox column on the database, then create a classic report and include a checkbox column and work from there: there is no functionality to break in that case.

            Edit: @Joni: you and i were concurrently updating :) I must've just changed the checkbox column from the apex_item definition that was there to just 'checkbox', and then changed it to be displayed as a "Simple Checkbox". I got a current row identifier error when trying to change the values to "Y,N".

            Edited by: Tom on Feb 4, 2013 10:19 AM
            1 person found this helpful
            • 3. Re: Yet another 'checkbox in Tabular Form' question
              Joni Vandenberghe
              Yeah sorry about that Tom, I usually take a copy :)
              • 4. Re: Yet another 'checkbox in Tabular Form' question
                John K.-Oracle
                Thank you both - that worked like a charm. I really appreciate the response and the great info. Thanks again!!