Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Create Search Definitions

If you want to define your own searches, you can do so using the SQL Editor, Query Builder or an Add-In, through the 'New Search' dialog. User-defined searches are stored in the user application data for the machine being used, and not in the project repository.



Explore > Search > Model : New search icon.    or

Design > Element > Manage > Search Model : New search icon.

Keyboard Shortcuts

Crtl+F : New search icon.   or

Ctrl+Alt+A : New search icon.

Create a new search definition



See also


Type a name for the search.

Query Builder

Click on this radio button to create your search through the internal search editor.

SQL Editor

Click on this radio button to create your search by directly writing SQL statements.

(For advanced users.)

Add-In Search

Click on this radio button to define the search as a function of an Add-In.

Add-In Name and Method

(Available if you have selected the 'Add-In Search' radio button)

Type in:

  • The name of your Add-In
  • A period (full stop) and
  • The name of the method to be called whenever the search is run (for example, MyAddin.RunThisMethod); this search can be exported and distributed as a part of your Add-In
Add-In Search


Click on this button to create the new search and close the dialog.

The search builder panel opens underneath the toolbar. For:

  • An Add-In search, no further action is required; click on the Edit search. icon to close the search builder panel
  • A Query Builder search, the panel defaults to the 'Query Builder' tab and you can start adding filters and constructing the search; see the Define and Modify Searches topic
  • An SQL search, the panel defaults to the 'Query Builder' tab and you can start to create the SQL statement for the search, as in Create SQL Search

The Search Builder also provides an 'SQL Scratch Pad' tab, which you can use to create and test SQL statements before copying them across to the 'Query Builder' tab.

SQL statements on the 'SQL Scratch Pad' are not attached to any search and are not the focus of any operations initiated from the 'Find in Project' toolbar.

Define & Modify Searches


Click on this button to abort the search creation and close the dialog.

Create SQL Search

You can create SQL statements using the SQL Editor through the 'Query Builder' tab. The SQL editor is based on the common Code Editor, and provides an Intelli-sense autocompletion list populated from the Enterprise Architect repository structure.

To display the autocompletion list, position the cursor after a command and press Ctrl+Space.

A simple search might be to locate an object from a table, given a search term that the user enters in the 'Search Term' field, such as:

     SELECT * FROM t_object WHERE NAME='<Search Term>'

In the WHERE statements you can also use #xxx# macros as string replacers, so that the same search can be used by different people in different environments. These macros are all case-sensitive. They include:



See also


Takes the user name from the 'Author' field in the 'Preferences' dialog 'General' page, so the defined search can be performed on objects created by that user (this value can be manually re-set in the 'Preferences' dialog).


Gets the IDs of the child Packages of the currently-selected Package, working recursively down to the lowest level of sub-Package. For example:

  • t_object.Package_ID IN (#Branch#)

#Concat value1, value2 ...#

Provides a method of concatenating two or more SQL terms into one string, independent of the database type.

#Datepart <field>, column#

Provides a method of querying one part of the Date, independent of the database type. The value of <field> can be one of:

  • year
  • month
  • day
  • dayofyear
  • weekday
  • week
  • dayname


Gets the ea_guid for the currently-selected element. For example:

  • t_object.ea_guid LIKE #CurrentElementGUID#


Gets the Object_ID for the currently selected element. For example:

  • t_object.Object_ID=#CurrentElementID#


<DBNAME> can be one of:

  • JET
  • ACCESS2007
  • ASA

This only uses the section of code between two matching #DB=<DBNAME># macros if the current database type matches the specified DBNAME; it can be used where a section of the SQL might require special handling depending upon the current database type. For example:

     #DB=ORACLE# t_object.ModifiedDate >= (SYSDATE - INTERVAL '<Search Term>' DAY) #DB=ORACLE#


Inserts the current date plus or minus a specified number of hours or days; the default is days (the date format is adjusted to suit the database in use) as in:

  • t_object.ModifiedDate >=#Now <Search Term>#

For example:

  • t_object.ModifiedDate >= #Now -4d#    d is days
  • t_object.ModifiedDate >= #Now -5h#    h is hours
  • t_object.ModifiedDate >= #Now +3#
  • t_object.ModifiedDate >= #Now#


Gets the Package_ID for the currently-selected Package. For example:

     t_object.Package_ID = #Package#


Gets the name of the person logged into Version Control. This example is from the built in search 'My Checked Out Packages'.

  • t_package.PackageFlags LIKE '#WC#VCCFG=#WC#CheckedOutTo=#UserName##WC#'


Gets the appropriate wild card for the current database, so the search can be performed on models on different databases. For example:

     t_object.Name LIKE '#WC#Test#WC#'

The GUID and Type

For all functions in which you use a custom SQL statement (including Document Reporting and Model Views) the statement must return the guid and type of the object found so that the system can search for the selected item in the Browser window. The SELECT statement is case-sensitive and should be typed as shown:

  • SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object

You can extend the usability of your SQL searches using the aliases CLASSGUID and CLASSTYPE, so that you can display the 'Properties' dialog, Tagged Values and icon for elements, connectors, attributes or operations, as well as selecting them in the Browser window. Some simple examples for using these aliased fields are:

  • SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object
  • SELECT ea_guid AS CLASSGUID, 'Operation' AS CLASSTYPE, Name FROM t_operation
  • SELECT ea_guid AS CLASSGUID, 'Attribute' AS CLASSTYPE, Name FROM t_attribute

Queries for connectors and diagrams can both return types that match the default association to object types. For these tables, you should also return a CLASSTABLE field to allow them to be distinguished from the similar object type.

  • SELECT ea_guid AS CLASSGUID, Connector_Type AS CLASSTYPE, 't_connector' as CLASSTABLE, Name FROM t_connector
  • SELECT ea_guid AS CLASSGUID, Diagram_Type AS CLASSTYPE, 't_diagram' as CLASSTABLE, Name FROM t_diagram

You can enable your search users to drag and drop elements from the search results onto a diagram, by including one of these in your search SELECT statement:

  • (t_object.Object_ID and t_object.Object_Type) or
  • t_object. ea_guid AS CLASSGUID

When you have defined the SELECT statement, click on the Save button in the 'Query Builder' toolbar to save this search; the search is then available from the 'Search' drop-down list.

SQL Scratch Pad Toolbar buttons

The 'SQL Scratch Pad' tab provides a small number of facilities through its toolbar.



Start test.

Click on this icon to test the search you have defined. The results display in the main panel of the 'Find in Project' view.

Click on this icon to save the current SQL search as a new search. A prompt displays for the new search name.

When you click on the OK button, the system switches to the 'Query Builder' tab, copies the SQL Statement to the tab, and puts the search name into the 'Search' field.

Click on this icon to clear the 'SQL Scratch Pad' of the current search definition.


  • When you create a custom SQL search on the 'Query Builder' tab, the only two icons that are available in the Toolbar are the Save icon and the Remove Filter icon Remove filter button.; the Remove Filter icon is effectively a Delete icon that removes the search content (the SQL statement)

Learn more