Advanced IVR Tutorial Lesson 2: Use Database Action
There is actually no need to write a Java program just for database access. IVR Studio provides a native database action for executing any SQL statement. To demonstrate the action, we use the same sample from this lesson but add the following: once a caller is authenticated, the application will update the database table and remember the access time.
Update the Database Table
Add a new column namedand set the column type to .
Update the Action
There is no need to update the call flow, except we need to change the Java action of theelement to a as follows:
This action provides all the functions implemented by the Java program shown in previous sections. It will load the database driver, connect to the database, execute the SQL statement, and then set the return to the action variable.
Create a new action to update the database
Select the element labeledand add the following action:
This action updates the user account and sets the Last_Login column to the current date and time.
Use SELECT statement
For database thestatement, DB action returns the whole result set in multiple name value pairs. Use the dot notation to access a particular result. The format of the dot notation is: where row_index starts from 1. For example, if you executed of db action , you can access the account_id using: and .
The total number of rows is also set in the action return variable. Use the dot notationto access it, such as .