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 named Last_Login and set the column type to "datetime".

Account_Id Account_Password Last_Login
101 123  
102 3456  

Update the Action

There is no need to update the call flow, except we need to change the Java action of the Check Password element to a Database action 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 labeled Protected Info and 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 the SELECT statement, DB action returns the whole result set in a JSON array. For more info, please see the blog article IVR app that uses database actions