5 Replies Latest reply: Mar 25, 2014 4:25 AM by juliojgs RSS

    Show the record number in an item (working in normal mode)

    juliojgs

      Hi,

       

      I need to show the record number in an item.

       

      This can be easily achieved in some statuses. I can make it work in query mode if I assign the :system.trigger_record value to the item in post-query.

      But, I want it to work even if I delete and/or insert new records between existing records.

       

      I supose I can do it with some record navigation everytime the user adds or deletes a record, but it is quite shabby, and would trigger record validation.

       

      Any wiser idea?

        • 1. Re: Show the record number in an item (working in normal mode)
          Michael Ferrante-Oracle

          I don't think I understand what you are asking.  You can use SYSTEM.CURSOR_RECORD to retrieve the record number for the record where the cursor is currently located.

          If you want to identify the record while INSERTing, UPDATEing, DELETEing, you can still use what you have already tried.  For example, in a PRE-UPDATE trigger add the following:

           

          if :system.trigger_record = '1' then

          message ('STOP');

          message ('STOP');

          RAISE FORM_TRIGGER_FAILURE;

          End if;

           

          This code would prevent you from updating record 1

           

          Similar could be done for PRE-INSERT and so on.

          • 2. Re: Show the record number in an item (working in normal mode)
            juliojgs

            No, it's not about that ... imagine a tabular block, with ten records shown and a scroll bar. I want a control item showing me the record number of each record.

             

            I execute query, and in the post-query I assign the system.trigger_record to the item. At this time, right after query, the block is ok. I see ten records, each one with its control item showing values from one to ten. I can scroll and my control item works ok.

             

            BUT, now, if I delete the fifth record, my control item will show values from 1 to 11, leaping over record 5.

             

            What I want is this item to recalculate itself, to show values from 1 to 10 even if I delete record #5.

            • 3. Re: Show the record number in an item (working in normal mode)
              Michael Ferrante-Oracle

              When you delete or insert a record (or scroll passed the last displayed record), it will be up to you to programatically update the items that are displaying your record numbers.

              • 4. Re: Show the record number in an item (working in normal mode)
                CraigB

                What value will you or your user get from displaying some sequential number like this?  I've had this conversation with users/customers before and in the end the answer was always the same - they just wanted to see the items with a sequential number.  The number meant nothing and the number was not stored in the database so depending on how you query your data for display, the number could change each time.  I strongly recommend you talk to whoever has given you this requirement and ask why they need this.  Also, let them know that doing this could cause your application to slow down when a re-numbering event occurs.  Looping through each record in the datablock consumes cycles and depending on the number of rows read into the datablock - this could take a lot of time.

                 

                Just my thoughts on the topic.


                Craig...

                • 5. Re: Show the record number in an item (working in normal mode)
                  juliojgs

                  Well, it's a list of tasks for a work order, they just want to see the steps numbered in real-time edit mode.

                  Of course, I don't think it does worth the work of programatically renumber every time they add or delete a task. They'll have to wait until commit or query. But this is the kind of think that seems easy for the end user who doesn't know a damn thing about forms.

                   

                   

                   

                  Still thinking ... maybe with another block, detail control block based somehow in the topmost record number of the main block ... but I'm not spending more time on this. Thanks for you time anyway.