Option four of the JDBC_SP sample application performs the Delete operation. For the delete operation, the user is prompted for an employee number and the user input is used to identify the record to delete from the database table. The Inline Code node for the Delete operation uses the following VXML code:
<var name="CHANNEL" expr="Channel"/>
<subdialog name="MyServlet" src="http://localhost/servlet/JdbcServlet" method="get" namelist="CHANNEL CMD TNAME CRITERIA DIPNAME">
<filled>
<if cond="MyServlet.retcode<='0'">
<prompt> Got a negative error code </prompt>
<goto expr="'#d3f8ult3x1tF0rm'"/>
</if>
<assign name="document.RetCode" expr="MyServlet.retcode"/>
</filled>
</subdialog>
<catch event="error.badfetch">
<goto expr="'#d3f8ult3x1tF0rm'"/>
</catch>
The namelist attribute specifies the arguments to be passed to the servlet, which are in turn used to perform the database operation. 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 code snippet, 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 DELETE in the SetDeleteParams 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 SetDeleteParams node. |
CRITERIA |
Specifies the Columns or database field names and corresponding values to insert into the specified database table. In this application, SETCOLUMNS has been declared as a character variable in the application and has been initialized in the SetInsertParams node. The SETCOLUMNS field should only be assigned a comma-separated list of strings that are in the format: "<DB_FLD1NAME>,<VALUE>,<DB_FLD2NAME>,<VALUE>,���.." |
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, 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 PAY and WIFE assuming that these were the fields specified in the most recent query operation.