Using the @Select Function

Objectives

After completing this lesson, you will be able to:

  • Use the @Select Function

The @Select Function

The @select function is a pointer to the Select statement of another object. It is used by placing the @select in the Selectfield of an object, using the following syntax:

  • @select (path of existing object)

You specify the path in the form of Folder_Name\Object_Name. The purpose of the @select function is to allow you to reuse existing code, giving the advantage of having to specify SQL code only once. There are two key advantages to specifying SQL only once:

  • Maintain only one instance of the SQL code.

  • Ensure consistency of the code

The code in the SELECT properties of the Model object is:

  • MODEL.MODEL_NAME+' '+ MODEL.MODEL_TRIM+' '+MODEL.MODEL_ENGINE

To create a new object called Model for Rental with the same Selectstatement, instead of creating the same code twice, you can refer to the original Model object via the @Select function:

  • @Select(Car\Model)

The benefit is that a dynamic link is created between the objects. When changes occur in the SELECTstatement of the original object, the changes are reflected in the SELECT statement of any other objects that refer to it via the @Select function. When you change the code, you change it only once in the original object.

Use the @Select Function

Rather than creating the same code twice, you want to reuse the code in the original Model object by referring to it using the @Select function.

Log in to track your progress & complete quizzes