Database Functions

Description
:    Database functions are used to access any JDBC compliance databases to access / validate database data during script runtime. Appropriate JDBC jar file should be added to the classpath to access the database.

Where the Database Functions can be used ?

Following is the scenario where Database Functions can be used,

How to insert database functions in the script ?
Following are the various functions available in the Database Functions category,
  1. getDBTableColumnCount
  2. getDBTableRowCount
  3. getDBValueAt
  4. getDBValues
  5. writeToDB
getDBTableColumnCount

 Function Description:

 Use this function to retrieve the Column count from Database after executing the specified sql query.

 How to Define:

 initDB("1.1")

result=getDBTableColumnCount("sql query")

 Example:

 initDB("1.1")

result=getDBTableColumnCount("Select * from LoginTable")

displayMessage(result)

In the above case,  the database will be initialized and the column count will be taken from the result set obtained by executing the query given. The column count will be stored in the variable named "result".

 Return Values:

 String - column count obtained from executing the sql query.

Top


getDBTableRowCount

Function Description:

Use this function to retrieve the Row count from Database after executing the specified sql query

How to Define:

initDB("1.1")

result=getDBTableRowCount("sql query")

Example:

To display the row count of the query result.

initDB("1.1")

result=getDBTableRowCount("Select * from LoginTable")

displayMessage(result)

In the above case,  the database will be initialized and the row count will be taken from the result set obtained by executing the query given. The row count will be stored in the variable named "result".

Return Values:

String - row count obtained from executing the sql query.

Top


getDBValueAt

 Function Description:

 Use this function to retrieve the value from the specified row and column from Database after executing the specified sql query.

 How to Define:

 initDB("1.1")

result=getDBValueAt("sql query,rowIndex,columnIndex")

 Example:

 To display the value at the 1st row, 2nd column value of the query result.

 initDB("1.1")

result=getDBValueAt("Select * from LoginTable",1,2)

displayMessage(result)

In the above case,  the database will be initialized and the given query will be executed to retrieve the  value from the given row , column index. The value obtained will be stored in the variable named "result".

 Return Values:

 String - value obtained from the row,column index.

 Top


getDBValues

 Function Description:

 Use this function to retrieve the databse values after executing the specified sql query. The database values will be stored in the result array.

 How to Define:

 initDB("1.1")

result=getDBValues("sqlquery")

 Example:

 To display all the values retrieved by the below query.

 initDB("1.1")

result=getDBValues("Select * from LoginTable")

for i in range (0,len (result)):

for j in range (0,len (result[i])):

displayMessage (result[i][j])

          In the above case, the database will be initialized and the query will be executed to retrieve the database values. The retrieved values will be stored in the result variable.The result array can be then iterated to use the retrieved data.

 Return Values:

 Two dimensional String array containing the retrieved values after executing the sql query.

 Top


writeToDB

 Function Description:

 Use this function to write the values in to database by executing the specified sql query.

 How to Define:

 initDB("1.1")

result=writeToDB("sql")

 Example:

 initDB("1.1")

result=writeToDB("Insert into employee ("emp_id","emp_name","dept") values("emp1","peter",payroll")")

In the above case, the database will be initialized and the query will be executed to insert the data in to the database. If insertion is successful then the "SUCCESS" value will be inserted.

 Return Values:

 0 for Success

1 for Failure

 Top


 



Copyright © 1999, AdventNet Inc. All Rights Reserved.