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 Search Builder tab. User-defined searches are stored in the user application data for the machine being used, and not in the project repository.

Access     Edit | Find in Project: Builder

Create a new search definition



See also


Click on the New Search icon in the toolbar.

The Create New Search Query dialog displays.




In the Search Name field, type a name for the search.




Select the radio button for the type of search you are creating:

Query Builder - provides an interface through which you can design your own search
SQL Editor - for advanced users to directly write SQL SELECT statements
Add-In Search - where you supply the name of your Add-In and a method (for example MyAddin.RunThisMethod), which is called whenever the search is run; this search can be exported and distributed as a part of your Add-In





Add-In Search


Click on the OK button, and refer to the next table.



Search Types



See also

Query Builder

Your search name appears as being selected in the Search drop-down field.

Click on the Add Filter toolbar icon to add filters and construct the search.


Add Filters

SQL Editor

The SQL editor displays within the Search Builder tab, in which you input your SELECT statement.

The SQL editor is based on the common Code Editor, and provides an Intelli-sense autocompletion list populated with the Enterprise Architect repository structure; to display the autocompletion list, press Ctrl+Spacebar.

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

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 include:

#WC# - Gets the appropriate wild card for the current database, so the search can be performed on models on different databases
t_object.Name LIKE '#WC#Test#WC#'
#Author# - Takes the user name from the Author field in the Options 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 Options dialog)
#DB=<DBNAME># where <DBNAME> can be one of the following:

Only uses the section of code between two matching #DB=<DBNAME># macros if the current database type matches the specified DBNAME. 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#

#UserName# - Gets the name of the person logged into version control
t_package.PackageFlags LIKE '#WC#VCCFG=#WC#CheckedOutTo=#UserName##WC#'
(this is from the built in search My Checked Out Packages)
#Now# - 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)
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#
#Package# - gets the currently-selected Package's package_ID
t_object.Package_ID = #Package#
#Branch# - gets the IDs of the child Packages of the currently-selected Package, working recursively down to the lowest level of sub-Package
t_object.Package_ID IN (#Branch#)


For all functions in which you use a custom SQL statement (such as Document Reporting or 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 Project Browser:

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 and icon for elements, connectors, attributes or operations, as well as selecting them in the Project Browser.

Some simple examples for using these aliased fields are provided below:

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

You can enable your search users to drag and drop elements from the search results onto a diagram, by including one or other of the following in your search's 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 to save this search; the search is then available from the Search drop-down list.


Code Editor Functions

Add-In Search

Type in:

The name of your Add-In
A period (full stop) and
The name of the method to be called (for example, MyAddin.RunThisMethod)


Your search is automatically saved and available from the Search drop-down list.


Add-In Search


When constructing an SQL search, do not switch to the SQL tab; this is for pasting in, modifying and running ad-hoc SELECT statements, and does not support the use of #xxx# macros

Learn more