Skip to main content
Previous section   Next section

Auto-Population

Now that we have created our Contact class, we can populate it with test data using the Caché auto-population tools. These are available to us because Contact extends %Populate.

Invoke the populate utility from the Terminal. Here are the steps:

  1. Launch Terminal. Do this by clicking the InterSystems Launcher (Caché cube images/tqks_cube.png, Ensemble icon images/tqks_ensemble_icon_20112.png, or HealthShare icon, depending on your system) in your system tray and then clicking Terminal on the launch menu.

    images/tqks_cubemenu_terminal_20112.png

  2. If the terminal is not pointing at the USER namespace, use the ZN command to switch to USER.

    
    SAMPLES>ZN "USER"
    USER>
    
    Copy code to clipboard
  3. Populate the namespace with ten Contact instances using the following command:

    
    USER>Do ##class(ContactDB.Contact).Populate(10)
    
    Copy code to clipboard

Here are the steps displayed in Terminal:

images/tqks_terminalswitchnamespace_20112.png

We can also launch an SQL shell from within terminal to view the newly created data. Here are the steps:

  1. Execute the following command to launch the shell:

    
    USER>Do $SYSTEM.SQL.Shell()
    
    Copy code to clipboard
  2. Next, enter an SQL query:

    
    USER>>SELECT NAME FROM ContactDB.Contact WHERE Type='Personal'
    
    Copy code to clipboard

Here are the steps displayed in Terminal:

images/tqks_terminalsqlshell_20112.png

Note:

To learn more about the Caché auto-population tools, read The Caché Populate Utility in Using Caché Objects.