## 5. Work with database

> 5.1 Introduction

> 5.2 Query component

> 5.3 Data function

## 5.1 Introduction

> This software supports working with databases. The ODBC, Sql Server and Oracle drivers are supported. Working with datases enables us to create arrays of celestial bodies, math functions, statistical selections etc. Database output may be connected to every database consumer. One of this consumer is database iterator. It iterates rows of database table.

## 5.2 Query component

Database component corresponds to the button. Its property editor is shown below:

This component enables us to select a database driver, connect to database and perform SQL query. The result of query may be used for science and engineering purposes. This component have also a diagram query editor. Press the Diagram button to open the editor. Then the following window appear.

This editor enables to select columns of database tables, link columns and set the "not null", ">", "<" and "=" conditions.

## 5.3 Data function

The database component may be used for construction of function . Let us consider the following examlple. It is necessary to install sample database to reproduce this example. Creation of sample data function contains the following steps.

Step 1.

Set the database component and insert connection string:

========== Connection string =============

user id=sa;data source=localhost;initial catalog=SELECTIONDB;integrated security=SSPI

====================================

and query:

========== Query =====================

SELECT Func.x, Func.y FROM Func ORDER BY Func.i

====================================

Step 2.

Put on desktop the compontent. Link it to the database component by a link. The picture looks like:

Step 3.

Open editor of properties of the component and select parameters like it is exhibited on the following picture:

Then this function may be used as external function in formula editor. Click here to download this scenario.