![]() |
||||||||||||||||||||||||||||||
Developing Database Scripts
![]() |
||||||||||||||||||||||||||||||
Table of ContentsDeveloping a Database ScriptDatabase Script Variables The Start Step The Accept Step The Play Prompt Step The DB Read Step The Label Step (Physician Loop) The DB Get Step The End Step Developing a Database ScriptYou can use the Cisco Customer Response Applications (CRA) Editor to design scripts that can access information from a specified database. One basic script can access information stored in a database. This chapter describes the design of such a script. This simple script, database.aef, uses steps from the Database palette to automatically provide callers with contact information for local physicians. In this sample script, the script reads all the data from a database table named physician_locator and plays back output one row at a time, looping back and repeating this process until there is no more data. Figure 8-1 shows the database.aef script as it appears in the Design pane of the CRA Editor window. Figure 8-1 database.aef Script Table 8-1 shows the physician_locator database table. This chapter contains the following sections: Database Script VariablesThe designer begins the database.aef script design process by using the Variable pane of the CRA Editor to define script variables. Figure 8-2 shows the variables of the database.aef script as they appear in the Variable pane of the CRA Editor. Figure 8-2 Variable Pane of the database.aef Script Table 8-2 describes the variables used in the database.aef script. Table 8-2 Variables in the database.aef Script
The Start StepEvery script built in the Design pane of the CRA Editor window begins with a Start step. The designer begins to build the database.aef script by choosing the File > New menu option from the CRA Editor menu bar. The CRA Editor places a Start step in the Design pane of the CRA Editor window. The Start Step needs no configuration and has no customizer window. The Accept StepThe designer continues the database.aef script by dragging an Accept step from the Contact palette (in the Palette pane of the CRA Editor window) to the Design pane, and dropping it over the Start step, as shown in Figure 8-1. Next, the designer configures this Accept step to accept an incoming call. Because the designer intends to accept the default contact, no configuration is necessary for this step. The Play Prompt StepThe designer continues the database.aef script by dragging a Play Prompt step from the Media palette to the Design pane, and dropping it over the Play Prompt step, as shown in Figure 8-1. The designer then configures the Play Prompt step to play a welcome message to the caller, announcing that the script will play back a list of physicians and their addresses. The designer then configures this Play Prompt step to play a welcoming prompt to the caller. Figure 8-3 shows the configured Prompt tab of the Play Prompt customizer window. Figure 8-3 Play Prompt Customizer WindowConfigured Prompt Tab The designer configures the Play Prompt step as follows: The step operates on the contact that triggers the execution of the script. External events can interrupt the playing of the prompt. (At this point the script has not yet queued the call, so this configuration has no effect.) WelcomePrompt is the prompt that the Play Prompt step plays back to welcome the caller. The caller can interrupt the prompt playback. In the event of a prompt error, the script continues to play back the next prompt in the sequence or waits for caller input. The system does not erase previously entered input before capturing new caller input. The DB Read StepThe designer continues the database.aef script by dragging a DB Read step from the Database palette to the Design pane. Next, the designer configures the DB Read step to use SQL (Structured Query Language) commands to read the physician_locator table in the specified database. Figure 8-4 shows the configured General tab of the DB Read customizer window. Figure 8-4 DB Read Customizer WindowConfigured General Tab The designer configures the General tab of the DB Read customizer window as follows: This choice names the query that is used by the subsequent DB Get step to read data from the database. This choice specifies the database that contains the desired information. Figure 8-5 shows the configured SQL tab of the DB Read customizer window, Figure 8-5 DB Read Customizer WindowConfigured SQL Tab The designer configures the SQL tab as follows: The DB Read step has three output branches, Successful, Connection Not Available, and SQL Error, as shown in Figure 8-1.) These following sections describe these output branches: The Successful Output BranchIf the DB Read step successfully reads the physician_locator table in the specified database, the script executes the Successful output branch. The designer configures the Successful output branch of the DB Read step to concatenate all the information extracted from the database and play it back to the caller. The Successful output branch is discussed in the following sections, beginning with The Label Step (Physician Loop). The Connection Not Available Output BranchIf the DB Read step does not successfully read the physician_locator table in the specified database, the script executes the Connection Not Available output branch, and the script falls through to the End step. The SQL Error Output BranchIf the DB Read step cannot execute because of an error in the SQL command, the script executes the SQL Error output branch, and the script falls through to the End step. The Label Step (Physician Loop)The designer begins the Successful output branch of the DB Read step by dragging a Label step from the General palette to the Design pane, and dropping it over the Successful icon under the DB Read step icon. The designer then configures the Label step to provide a target for the beginning of a loop that will repeat until all the names in the database have been read back to the caller. After the DB Read step, the designer uses a DB Get step within a Label step defined as Physician Loop. (See Figure 8-1.) The DB Get StepThe designer continues the Successful output branch of the DB Read step by dragging a DB Get step from the Database palette to the Design pane, and dropping it over the Label step icon under the Successful icon under the DB Read step icon. The designer then configures the DB Get step to retrieve the information in the physicians_locator database. Figure 8-6 shows the configured General tab of the DB Get customizer window. Figure 8-6 DB Get Customizer WindowConfigured General Tab In the DB Resource Name text field, the designer specifies "getPhysicians", which is the query that retrieves one row of data at a time from the physician_locator table. Figure 8-7 shows the configured Field Selection tab of the DB Get customizer window. Figure 8-7 DB Get Customizer WindowConfigured Field Selection Tab The designer uses the Field Selection tab to associate each field in the database table with a local variable. The DB Get step has three output branches, Successful, No Data, and SQL Error. (See Figure 8-1.) These following sections describe these output branches: The Successful Output BranchIf the DB Get step successfully obtains data from the database table and stores the data in the defined variables, the script executes the Successful output branch. The designer configures the Successful output branch of the DB Get step to concatenate all the information extracted from the database, play it back to the caller. The Successful output branch contains two steps, discussed in the following sections: The Play Prompt StepThe designer begins the Successful output branch of the DB Get step by dragging a Play Prompt step from the General palette to the Design pane, and dropping it over the Successful icon under the DB Get step icon. The designer then configures the Play Prompt step to play back to the caller the information retrieved from the database table. Figure 8-8 . shows the configured Prompt tab of the Play Prompt customizer window. Figure 8-8 Play Prompt Customizer WindowConfigured Prompt Tab The designer sets the Prompt variable to the following expression: "Spoken_Name + DP[250] + S[Phone] + DP[250] + S[Address] + DP[250] + S[Name] + DP[250] + S[Category] + DP[250] + S[Zip_Code]" This expression represents a prompt concatenation where the Play Prompt step plays back the Document variable Spoken_Name as a prompt. DP[250] stands for 250 milliseconds of silence. All the S[xx] elements represent the xx String variables that the Play Prompt step converts to a prompt that spell out the contents of the variables. The Goto Step (Physician Loop)The designer ends the Successful output branch of the DB Get step by dragging a Goto step from the General palette to the Design pane, and dropping it over the Play Prompt step icon under the Successful icon under the DB Get step icon, as shown in Figure 8-1. The designer then configures the Goto step to instruct the script to loop back to the DB Get step and continue to retrieve a row of data from the table each time this step executes. When the script reads every row of data and no data is found, the script automatically drops down to the DB Get step No Data output branch. (See The No Data Output Branch.) The No Data Output BranchIf the DB Get step does not find any data in the database table, or reaches the end of the table, the script executes the No Data output branch. The No Data output branch contains four steps, discussed in the following sections: The DB Write StepThe designer begins the No Data output branch of the DB Get step by dragging a DB Write step from the Database palette to the Design pane, and dropping it over the No Data icon under the DB Get step icon, as shown in Figure 8-1. The designer then configures the DB Write step to search the database table for entries for which the zip code is 99999 and delete them from the table. Figure 8-9 shows the configured General tab of the DB Write customizer window. Figure 8-9 DB Write Customizer WindowConfigured General Tab The designer configures the General tab of the DB Write customizer window as follows: You assign this name to identify this database query. This variable specifies the database that contains the desired information. Figure 8-10 shows the configured SQL tab of the DB Write customizer window. Figure 8-10 DB Write Customizer WindowConfigured SQL Tab The designer configures the SQL tab as follows: This SQL command tells the step what to write to the database table. Using the data in Table 8-1 , the DB Write step deleted the last row of the table. The DB Write step has the following three output branches, (each of which fall through to the DB Release step): The DB Release StepThe designer continues the No Data output branch of the DB Get step by dragging a DB Release step from the Database palette to the Design pane, and dropping it over the DB Write step icon under the No Data output branch of the DB Get step icon, as shown in Figure 8-1. The designer then configures the DB Release step to close the SQL query and release the allocated resources. The system returns the released DB connection to the connection pool, and no longer associates data with this connection. Figure 8-11 shows the configured DB Release customizer window. Figure 8-11 Configured DB Release Customizer Window In the DB Resource Name text field, the designer specifies getPhysicians as the DB Resource to be released. The Terminate StepThe designer continues the No Data output branch of the DB Get step by dragging a Terminate step from the Contact palette to the Design pane, and dropping it over the DB Release step icon under the No Data output branch of the DB Get step icon, as shown in Figure 8-1. The designer then configures the Terminate step to terminate the outgoing call. The End StepThe designer end the No Data output branch of the DB Get step by dragging an End step from the General palette to the Design pane, and dropping it over the DB Terminate step icon under the No Data output branch of the DB Get step icon, as shown in Figure 8-1. The End step ends the script and releases all system resources. The End step requires no configuration and has no customizer. The SQL Error Output BranchIf the DB Get step does not execute because of a SQL command error, the script executes the SQL Error output branch, and the script falls through to the End step to end the script. The End StepThe designer concludes the database.aef script by dragging an End step from the General palette to the Design pane, and dropping it over the DB Read step, as shown in Figure 8-1. The End step ends the script and releases all system resources. The End step requires no configuration and has no customizer.
|
||||||||||||||||||||||||||||||
|
|