database_adaptor [TAST DokuWiki ]

User Tools

Site Tools


Sidebar

First steps in TAST

What is UML

Computer setup for TAST use

FAQ

Recognized Issues

TAST tool Menu

TAST Adaptors

Adaptors examples

TAST Integrations

Interesting features

Documentation of technical administration

Modeling recommendations

Training in the TAST tool

database_adaptor

Database Adaptor

Setup

In the initialization process the Database Adaptor requests the necessary data to establish the connection with the destination database, and tries to make the connection. If it fails, the process is aborted.

Initialization Parameters

  • Host: Represents the IP address or the machine's DNS name where the database resides.
  • Port: The port number that listens for incoming connections to the database.
  • DbName: Name of the instance or database service.
  • User: User name.
  • Password: User password.
  • DbType: Indicates the provider or type of database to which we want to connect.

Functions

  • connect_DB(): Tries to connect to the configured database. Returns true if it succeeds or false otherwise. On the properties of the object in the Database Adaptor there are some parameter boxes to do the configuration about the Database we are going to use. There will be, once the function is executed, a log with different messages if the connection was a succeed or not.
  • dBExecuteStatement(Statement): Executes the SQL that it's contain in the parameter (statement). Allows the user to modify the data in the destination database. This function allows you to write SQL statements like Insert, Delete, Update and Merge in the statement parameter. The function will replace the variables for their values in the execution time, that will return a TastInteger with the number of rows that were changed. (Input parameter: The sentence for example:” INSERT INTO x (a, b, c) VALUES (d, e, f)” Output parameter: Integer with the results).
  • dBGetQueryData(Query): Executes the SQL Select statement contained in the Query parameter, and returns the results as a TastTableData variable to the executor, which allows access and work with the data in later steps of the diagram. The Query parameter contains the Select statement to execute in the database. It is possible to use variables created in the diagram within the Query parameter, the function will substitute the variables for their values at run time.(Input parameter (Query), Output parameter (OutputTable)).
  • disconnect_DB(): Tries to disconnect from the database. Returns true if it succeeds or false otherwise. (As the function connect_DB this function returns an error message if the disconnection fails otherwise returns a succeed message).
  • getNumColumns(): Returns the number of columns contained in the TastTableData that was generated by the execution of the dBGetQueryData function. It requires the execution of the dBGetQueryData function in previous steps of the diagram. (Don’t need an input parameter, so it’s a function that just return the number of columns of the selected table (with TastTableData)).
  • getNumRows(): Returns the number of rows contained in the TastTableData that was generated by the execution of the dBGetQueryData function. It requires the execution of the dBGetQueryData function in previous steps of the diagram. (Don’t need an input parameter, so it’s a function that just return the number of rows of the selected table (with TastTableData)).
  • getTableValue(RowNum, ColNum): Returns the value contained in the cell indicated by the parameters Row and Col. It requires the execution of the dBGetQueryData function in previous steps of the diagram. (Input parameters are the row and the column you need to display, and the output should be the information contained there).
  • tableRecordCount(TableName, WhereClausule): Performs a SQL query using the SQL Count (*) function. The tableName parameter represents the name of the table or view to be used for the Query, and the whereClausule parameter represents the SQL where clause that we must apply. Returns the number of rows counted by the sentence.

Managing Variables in the database Adaptor

The management of variables in the DB Adaptor is an important topic, especially it is important how the variables are handled within the predefined function of the query.

  • Instead of supporting parameters, its better to substitute them using this syntax, with Data being the variable to replace,'”+ #Data +”' (single quote, double quotes). For example:

    SELECT '” + #Data + ”' FROM dual
  • In addition, queries have often used an alias that is enclosed in quotes. For example:

    SELECT domain FROM dual as “Domain”
  • If complex queries are manipulated, with several aliases in which you want to substitute several variables, it works by building in a javascript the complete query, being necessary to jump the quotes ”” of the aliases with this symbol: \. For example:

    SELECT domain FROM dual as \ “Domain” \
database_adaptor.txt · Last modified: 2022/09/19 11:07 by montse