Using the @Where Function

Objectives

After completing this lesson, you will be able to:

  • Use the @Where Function

The @Where Function

The @Where function is a pointer to the WHERE clause of another object. It is used by placing the @Where in the Where clause of an object, using the following syntax:

  • @Where (path of existing object)

If you wish to create a new object called Model for Rental that contains the same WHERE syntax, rather than creating the same code twice, you can refer to the original Showroom Choice object via the @Where function:

  • @Where(Where Restriction Objects\Showroom Choice)

The benefit is that a dynamic link is created between the objects. When changes occur in the WHERE clause of the original object, the changes are reflected in the WHERE clause of any other objects that refer to it via the @Where function. Therefore, to change the syntax, you only change it once in the original object.

As with @Select, its purpose is to allow you to reuse existing code, and it has the same advantages:

  • Maintain only one instance of the SQL code.

  • It ensures consistency of the code.

If there are a number of objects or condition objects that require the same SELECT or WHERE be placed upon them, use an object strategy to make the most efficient use of that code.

The idea behind the strategy is that you create a new and separate object for every reused SELECT/WHERE and keep them in a separate folder.

Hide the folder containing the SELECT/WHERE objects from end users by right-clicking the folder and selecting Change stateHidden.

Hidden folders and objects appear in italics in the business layer pane. They are not shown at all in the end-user querying tools.

Then create objects/predefined filters in appropriate Active folders that reference the appropriate object in the Hidden folder.

Use the @Where Function

You want to use the @where function to point to the WHERE clause restriction objects.

Log in to track your progress & complete quizzes