Re: looping through items in a block

From: DanHW <danhw_at_aol.com>
Date: 19 Jun 1998 04:08:54 GMT
Message-ID: <1998061904085400.AAA00594_at_ladder03.news.aol.com>


>I am using Developer 2000 to create an application. I would like to restrict
>the type of searches that a user can do on the database. I want to make sure
>that they do not use the '%' in the first column of any item they are
>querying on. If there a way to loop through the values of all of the items in
>a block without knowing the names or the id of the items? I would like to
>prevent this type of search without writing code in every item's
>WHEN-VALIDATE-ITEM trigger. I would like to write one function that takes one
>parameter (i.e. a block), scans through all of the item's values and then
>return TRUE or FALSE based on their values.
>
>

There is a block property - 'FIRST_ITEM' or something close that will tell you the item with sequence #1. There is an ITEM property "NEXT_ITEM" that returns the next-higher sequenced item. I have used this in old versions of Forms to loop through all the fields in a block.

I don't remember how to determine the end - I think there is a LAST_ITEM that you can check; or maybe on the last item the 'NEXT_ITEM' is null, or repeats.

There might be some issues related to data types - a real number field, during a query, is allowed to hold (some) non-numeric characters.

As I have been writing this, a different approach came to mind. Create a when-new-item-instance trigger on the block (that fires during query mode), that checks if you are in entry-query mode. If so, use the SYSTEM.CURSOR_VALUE variable (which is a character string) and look in it for any disallowed characters, and raise form_trigger_failure if you need.

Good Luck

Dan Hekimian-Williams Received on Fri Jun 19 1998 - 06:08:54 CEST

Original text of this message