Option one of the JDBC_SP sample application performs the Select operation. The Inline Code node for the Select operation uses the following VMXL code:
<var name="CHANNEL" expr="Channel"/>
<subdialog name="MyServlet" src="http://localhost/servlet/JdbcServlet" method="get" namelist="CHANNEL CMD TNAME CRITERIA GETCOLUMNS DIPNAME">
<filled>
<if cond="MyServlet.retcode<='0'">
<prompt> Got a negative error code </prompt>
<goto expr="'#d3f8ult3x1tF0rm'"/>
</if>
<assign name="document.RetFieldNum" expr="MyServlet.EMPNUM"/>
<assign name="document.RetField2" expr="MyServlet.PAY"/>
</filled>
</subdialog>
<catch event="error.badfetch">
<goto expr="'#d3f8ult3x1tF0rm'"/>
</catch>
As shown in the code above, the VXML subdialog tag is used to invoke the servlet from the VMXL code. In this example, the subdialog is named MyServlet. JdbcServlet is the servlet provided by Avaya for JDBC access and is specified in the src attribute. The data is sent over to the servlet by the get method. The namelist attribute specifies the arguments to be passed to the servlet, which are in turn used to perform the database operation. All the fields specified for the namelist attribute need to exist as application variables in the IVR Designer application. The following table describes the fields:
Field |
Description |
CHANNEL |
Specifies the channel number of the call in progress. IVR Designer provides a system variable called Channel in every application for this use. As can be seen from the first line in the VXML code, the system variable Channel is copied into the local CHANNEL variable. |
CMD |
Specifies the database command to perform. In this application, CMD has been declared as a character variable in the application and has been initialized to the string SELECT in the SetSelectParams node. |
TNAME |
Specifies the Table Name to perform the database operation on. In this application, TNAME has been declared as a character variable in the application and has been initialized to the string JDBC_TBL in the SetSelectParams node. |
CRITERIA |
Specifies the Criteria for the select operation. In this application, CRITERIA has been declared as a character variable in the application and has been initialized to the string EMPNUM=12345 in the SetSelectParams node. The Criteria field should only be assigned a comma-separated list of strings that are in the format: "<DB_FLDNAME=<VALUE>". The "=" operation can be replaced by any of the operators: '<', '<=', '>', '>=', '!='. An example of specifying multiple criteria in this application would need CRITERIA to be set to the following: "EMPNUM=12345,PAY='100000'" |
GETCOLUMNS |
Specifies the Columns or database field names to return from the query operation. In this application, GETCOLUMNS has been declared as a character variable in the application and has been initialized to the string EMPNUM,PA in the SetSelectParams node. PAY and WIFE are column names in the JDBC_TBL table being used in this example. |
DIPNAME |
Specifies the DBDIP on the Avaya IR platform that should be used for accessing the database. One of the DIPs on the IR platform should be configured using the Web Administration interface to be able to access the required database. In this application, TNAME has been declared as a character variable in the application and has been initialized to the string DBDIP2 in the Variables Manager. |
As shown in the VXML code above, a retcode value is always returned from the servlet indicating the success or failure of the servlet and database operation. The retcode field will contain a positive value if the operation was successful. In this example, an error prompt is being played if the retcode contains a value less than or equal to zero. Other values returned from the servlet can be assigned to application variables. In this case, the servlet returns EMPNUM and PAY, since they were identified in the GETCOLUMNS parameter as fields to be returned.