GainSeeker SQL Utility

The GainSeeker SQL Utility is a powerful tool that can be used to execute Structured Query Language (SQL) functions, including:

Note: You can have multiple copies of this utility running simultaneously in GainSeeker.

Caution: If you are not confident in your SQL abilities, defer this activity to a database administrator. Always perform backups of your data tables prior to using this utility.

 

Contents  [Hide]

 

Accessing the SQL Utility

The SQL Utility is accessed from the SQL Utility button on the GainSeeker Utility module:

When you click the SQL Utility button, GainSeeker displays this warning:

Select Database

The Select Database button lets you change to another database connection. You can choose either from the list of stored database connections or add a new temporary database connection. The temporary database connection only lasts during this SQL utility session.

SQL Assistant

The SQL Assistant button makes it easy to change data without needing to create your own SQL statements.

System and Change type

Choose whether to change data in the SPC or in DMS system, then choose whether to change Data, Standards, or Process for that system.

Field to change

For the System and Change type that you selected, this lists all of the fields that are available to update.

Current value

For the Field to change that you selected, this lists all of the values currently stored in the current GainSeeker database.

New value

For the Field to change that you selected, this displays the pre-defined list (of traceability values, existing standards, or existing processes - depending on the field you selected) for that field.

SPC Standards

If you chose the System "SPC" and the Field to change "Part Number", you can click this button to create, edit or delete SPC Standards.

SQL statement(s)

As you select options for System, Change type, Field to change, Current value, and New value, GainSeeker automatically creates SQL scripts to carry out those changes.

Some items like filters, priority lists, etc. cannot be changed by SQL Utility.  These will also be listed in the SQL statement(s) box.  You should use other GainSeeker modules to manually update these items with the New value.

Execute (F5)

After selecting all of the desired options on this window, click this button or press the F5 key to execute the queries and carry out the update.

Examples

Composing SQL Statements

The following buttons can be used to help compose SQL statements:

For more information, see Help for typing SQL statements and  Sample SQL Statements.

Multiple SQL statements

Multiple SQL statements can be executed at once, but only one result set will display.

Stored procedures

You can call stored procedures from the SQL Utility.

To execute a stored procedure that does not return a result set, simply run the stored procedure.  Depending on the database, the syntax may be different. For example, to run a stored procedure in Pervasive.SQL you type CALL <stored procedure name>. In Oracle, type EXEC <stored procedure name>. In Microsoft SQL Server, type EXEC <stored procedure name> or simply the name or the stored procedure with no keyword.

Note: GainSeeker does not display returned result sets from stored procedures.

Right-click menu options for composing SQL Statements

Import from File and Export to File

Use these options to open a saved SQL statement (Import), or to save your current SQL statement for later use (Export).

Orphaned Data

This function queries data tables for all data records in auxiliary tables that do not have matching records in the corresponding master table. This will display the count of orphaned records for each of the auxiliary data tables with corresponding SQL statements to delete these records in the SQL text field. These statements can then be uncommented and executed as desired. If no orphaned data is found, a message will appear in the SQL text field alerting you that no records were found.

Note: Remember that deleting these records is permanent. It is impossible to recover this data once it is deleted.

Working with Query Results

Each time you execute a SQL statement, GainSeeker will use the bottom pane in this window to display any messages returned by your database server - number of records affected, errors, etc.

Additionally, if you executed a SELECT statement that returned one or more values (such as data records, a list of distinct values in one database column, etc.), the middle pane of this window will show those values on grid. When this grid is displayed, you can: