DB_INSERT

This command uses the contents of the record buffer to store DMS data to the GainSeeker database.

Syntax

DB_INSERT connection_number, "database_type"

connection_number

Valid options for connection_number are the numbers 1 through 10.

You should use this parameter to specify the number of the connection that was created by the Q_CONNECT command.

"database_type"

The only valid option for this parameter is "DMS".

Return value

This command returns one of the following numbers:

Return value

explanation

1

DMS data was successfully stored in the database.

2

DMS data with the same standard and date/time stamp already existed in the database.

The "DateTime" tag in the record buffer has been incremented as needed to arrive at a unique date/time stamp for this standard, and DMS data was stored successfully with this updated date/time stamp. The unit of time that was incremented – Minutes, Seconds or Hundredths of seconds – is based on the Show time to setting in the current configuration.

0

DMS data was not stored in the database.

To find the reason why data could not be stored, use the Q_ERRORDESC and Q_ERROR commands.

Notes

This command will store a record to the DMS Data table name (e.g., "DDATA") for the current configuration – and, if needed, to the DMS Data Auxiliary table name (e.g., "DDAT_AUX") – on the specified database connection number.

If you have removed unused columns from the DDAT_AUX table in the current configuration, this command will automatically detect which traceability columns remain and will adjust the SQL string accordingly.

This command does not store a note for this DMS data record. If you need to store a note for this DMS data record, you must use the Q_EXECUTE and DB_NOTE_SQL commands.

Examples

DB_INSERT 1, "DMS"

This formula uses the contents of the record buffer to store DMS data to the DMS Data table name for the current configuration – and, if needed, to the DMS Data Auxiliary table name – on database connection number 1.

IF (DB_INSERT 1, "DMS") > 0, "", (MESSAGE Q_ERRORDESC, Q_ERROR)

This formula uses the contents of the record buffer to store DMS data to the DMS Data table name for the current configuration – and, if needed, to the DMS Data Auxiliary table name – on database connection number 1. If there is an error storing the DMS data, this formula will display the database error message and error number.

Sample template to collect and store defect data:

Cell

Column

Method and
User Message

Formula

Explanation

A1

Calculated

Formula

DMS_OPT 0, 0 :

DMS_OPT 8, 1 :

DMS_OPT 9, 1 :

DB_RESET 0

  Reset attribute data entry options to default settings

 Configure this template to automatically set the number of defective units equal to the number of defects

 Configure the defect entry screen to display the Note button

 Clear the record buffer

B1

Calculated

Formula

Q_CONNECT 1, "<default>", "Y", "N"

Connect to the GainSeeker database

C1

Dept.

Keyboard

Choose your Dept. from the list:

 

Prompt the user to enter traceability information

D1

Calculated

Keyboard

Enter Sample Size:

 

Prompt the user to enter the sample size

E1

Calculated

Formula

IF [D1] < 1,

(MESSAGE "Sample Size must be a number greater than 0. Please re-enter the sample size.")
+ GOTO [D1]

Check the sample size to make sure it's a positive number

F1

Calculated

Formula

DB_SET_VALUE "Trace_3", [C1] :

DB_SET_VALUE "Sample_Size", [D1]

Set the record buffer values for traceability field 3 (Dept.) and sample size

G1

Calculated

Formula

DMS_COUNTS "T-55ST", "INCOMING", ""

 Display the defect entry screen for Part Number "T-55ST" and Process "INCOMING"

 Apply the date/time stamp from the computer clock

H1

Calculated

Formula

IF [G1] = 0,

(   IF (YESNO "Are you sure you want to Cancel? This will exit the template without saving your data."),

EXIT,

GOTO [D1]   ) :

IF [G1] = -1,

(MESSAGE "An error has occurred. Please contact your System Administrator.")
+ EXIT

Check the results of the defect entry screen:

 If the user clicked Cancel, give them the choice to keep entering data or exit

 If some kind of error has occurred, display a message and exit

I1

Calculated

Formula

DB_INSERT 1, "DMS" :

IF (LEN (DB_VALUE "Note")) > 0,

(Q_EXECUTE 1, DB_NOTE_SQL "DMS*") :

DB_RESET 0

 Save this defect data record

 If a note was entered, save this defect note record

 Clear the record buffer

J1

Calculated

Formula

IF [I1] = 0,

(MESSAGE "An error has occurred. Please contact your System Administrator.")
+ EXIT

If there was an error storing the data, display a message and exit

K1

Calculated

Formula

IF (YESNO "Enter more data for this Department?"),

GOTO [D1],

EXIT

Allow the user to enter another data record or exit