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

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.

Access     Edit | Search Model: NewSearchIcon

Create a new search definition

Field/Option/Button

Action

See also

Name

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

OK

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 editsearch 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 Create 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, below
 

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

Cancel

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+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, 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 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:
·MYSQL
·JET
·ORACLE
·SQLSVR
·ASA
·OPENEDGE
·POSTGRES

 
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#
 

·#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 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.

Icon

Description

See also

StartTestIcon

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

 

 

SaveAsNewSearch

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.

 

 

ClearSQL

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

 

 

Notes

·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 RemoveFilter icon; the Remove Filter icon is effectively a Delete icon that removes the search content (the SQL statement)

Learn more