GoldMine Application Programming Interface Specification and Reference


GMW_DS_Fetch’s Return Packet Explained



Download 465.93 Kb.
Page2/4
Date31.01.2017
Size465.93 Kb.
#14243
1   2   3   4

GMW_DS_Fetch’s Return Packet Explained


GMW_DS_Fetch returns a single packet string containing the data from all requested records. The packet includes a header record, followed by one record for each record evaluated by “fetch.” Within each record in the packet, the fields are separated by a field delimiter specified in GMW_DS_Range or GMW_DS_Query. By default, the field delimiter is the carriage return character (13 or 0x0D).
The records in the packet are separated by the record delimiter. By default, the record delimiter is the line feed character by default (10 or 0x0A).
These delimiters are convenient when the requested data does not contain notes from blob fields. When requesting notes, override the default delimiters by passing other delimiter values to GMW_DS_Range() and GMW_DS_Query(). For packets with notes, good delimiters are the ASCII characters 1 and 2.
GMW_DS_Fetch might return a packet of data similar to:
3000-0004

Bill|Boston|23

Michael|London|393

Calvin|Los Angles|633

Larry|New York|29
The packet header record consists of two sections:


  • First byte can be 0, 3, or 4:

0 - indicates that more records are available, which could be fetched with another GMW_DS_Fetch call

3 - indicates the end-of-file (EOF)

4 - indicates the beginning-of-file (BOF)

  • The number following the dash (0004 in the sample above) indicates the total number of data records contained in the packet.

Syntax: GMW_DS_Fetch( <iHandle>, <szBuf>, <iBufSize>, <nGetRecs> )


Parameters: <iHandle> The Datastream handle returned by GMW_DS_Range or GMW_DS_Query

<szBuf> Buffer to hold result packet

<iBufSize> Size of returned

<nGetRecs> Number of records to fetch.
GMW_DS_Close

GMW_DS_Close must be called when the DataStream operation is complete. Unclosed DataStreams will leak memory and leave the database connections needlessly open. Passing a Handle of 0 closes all open DataStream objects.


Syntax: GMW_DS_Close( <iHandle>)
Parameters: <iHandle> The Datastream handle returned by GMW_DS_Range or GMW_DS_Query
Returns: 1 Success

  1. Failure



GM5S32.DLL - Low-Level access using Work Areas

Introduction

GoldMine’s GM5S32.DLL provides a complete set of functions that allow low-level access to the database tables. Using these functions, you can:


  • Open/Close particular data files

  • Append/Delete records

  • Reading and writing data

  • Limiting the scope of data

  • Searching for data

  • Navigating through the database

Note! These functions allow direct access to the data and require a very sophiscated knowledge of the GoldMine schema and database methodology. It is highly recommended that before resorting to these functions you first look at the Business logic functions to handle your needs. The Business Logic functions actually wrap these low-level functions and use them properly and are therefore “safer” to use.
Database applications that need varied access to GoldMine data typically use this suite of functions. To work successfully, these functions rely on a work area parameter. Using this parameter, you can open multiple data files concurrently, and manipulate each file independently by referencing the file by work area. These functions also maintain synchronization information, which is stored in the TLogs.
Detailed descriptions of each database access function appear on the following pages. Some of the following functions make reference to table names, field names, and index names. For details, see “Database Structures” in the GoldMine Reference Manual and/or Help file.
Opening/Closing databases

These are functions important to all other low-level operations. Opening and closing databases is required for proper operation of all other low-level functions.


GMW_DB_Open

Opens one of GoldMine’s data files for processing by another application.


Syntax: GMW_DB_Open( <szTablename> )
Parameters: <szTableName> The name of the table to open. You may use a full path if required for dBase tables
Returns: >0 Success – A Work Area handle is returned

  1. Failure

GMW_DB_Close

Releases a previously opened file when processing is complete. All previously opened files must be properly closed—failure to do so can result in database errors.
Syntax: GMW_DB_Close( <lWorkArea> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.
Returns: 1 Success – Table Closed

0 Failure


GMW_DB_IsSQL

Used to determine if the table is SQL or dBASE.


Syntax: GMW_DB_IsSQL( <lWorkArea> )
Parameters: <lWorkArea> The work area handle as returned by GMW_DB_Open
Returns: 1 Table is SQL

  1. Table is dBase

Creating and Deleting Records

The following functions will allow you to add and delete records from the database.
GMW_DB_Append

Adds a new, empty record to a GoldMine data file. Before using GMW_DB_Append, you must open a data file using the GMW_DB_Open function. After executing the GMW_DB_Append function, the record pointer is positioned at the new empty record, and the record is locked and ready to accept field replacements. This function will lock the record so you should always call GMW_DB_Unlock when finished using this function.


When a CONTACT1 record is appended, GoldMine automatically fills in the new record with the appropriate ACCOUNTNO and CREATEBY values. For all other table records, you must replace the ACCOUNTNO field with the value from the CONTACT1 record with which the new record is to be linked. For records that require remote synchronization initialization, GoldMine will automatically fill in the value of the RECID field when these records are appended.
Syntax: GMW_DB_Append( , )
Parameters: The work area handle as returned by GMW_DB_Open

A 20-character buffer to accept the new RecID
Returns: RecNo of new record (dBase)

RecID of new record is returned in (SQL)



  1. failure

GMW_DB_Delete

Deletes the current record in the specified work area, and moves the record pointer to the next record.

For records that require remote synchronization initialization, GoldMine will automatically maintain the TLog entry.


Syntax: GMW_DB_Delete( <lWorkArea> )
Parameters: <lWorkArea> The work area handle as returned by GMW_DB_Open
Returns: 1 Success

0 Failure


Reading/Writing Data

The following functions allow you to read and write to the database.
GMW_DB_Read

Queries a data file for the value of a field.


Syntax: GMW_DB_Read(l <lWorkArea>, <szField>, <szBuf>, <iBufSize> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

Tthe name of the field to read within the table.

The buffer in which the function will return the results.

Specifies the size of the buffer.

Returns: 1 Success

0 Failure
GMW_DB_RecNo

Used to determine either current record number (dBASE), or the RecID (SQL).


Syntax: GMW_DB_RecNo( <lWorkArea> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.
Returns: RecNo dBase returns the current record number.

RecID SQL returns the current RecID.


GMW_DB_Replace

Changes the value in a particular field in one of GoldMine’s data files. You should always call GMW_DB_Unlock when finished using this function.


Syntax: GMW_DB_Replace(long lWorkArea, char *szField, char *szData, int iAddTo)
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

Specifies the name of the field to be replaced.

Specifies the data to be placed in the field.

Indicates if the data is to be appended to the existing data. A value of 1 will append the data. A value of 0 will overwrite the data.
Returns: 1 Success

  1. Failure

GMW_DB_Unlock

Unlocks a record previously locked by a call to either GMW_DB_Append or GMW_DB_Replace. under SQL, an optimistic lock replace failure will suppress the UI and cause GMW_DB_Unlock to return FALSE.
Syntax: GMW_DB_Unlock( <lWorkArea> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.
Returns: 1 Success


  1. Failure

Limiting scope of data

These functions will limit the scope of data available. You might wat to limit the data to only those records in a particular state for example. Using scopes wisely can greatly increase performace for subsequent operations.


GMW_DB_Filter

Limits access to data in a GoldMine database by creating a subset of records based on expression criteria. This function is similar to GMW_DB_Range. If successfully called, all other functions (GMW_DB_Top, GMW_DB_Bottom, GMW_DB_Skip, etc.) will respect the filter.


Syntax: GMW_DB_Filter( <lWorkArea>, <szFilterExpr>)
Parameters: <lWorkArea> The work area handle as returned by GMW_DB_Open

<szFilterExpr> An xBase filter expression.
Returns: 1 Success

0 Failure

GMW_DB_Range

Activates the index in a table, and set a range of values to limit the scope of data that GoldMine will search. This function is faster than GMW_DB_Filter. The Min and Max values must be formatted the same as the selected index name’s expression. If successfully called, all other functions (GMW_DB_Top, GMW_DB_Bottom, GMW_DB_Skip, etc.) will respect the range.


Syntax: GMW_DB_Range( <lWorkArea>, <szMin>, <szMax>, <szTag>)
Parameters: <lWorkArea> The work area handle as returned by GMW_DB_Open

<szMin> Minimum or lower value of the range.

Maximum or upper value of the range.

<szTag> the index name.
Returns: 1 Success

0 Failure


Searching for data

These functions allow you to perform searches on the database.


GMW_DB_Search

Performs a sequential search on a file.


Syntax: GMW_DB_Search(<lWorkArea>, <szExpr>, <szRecID>)
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

Valid dBase expression. For a record to be “found” this expression must result as TRUE.

Buffer where the return value is stored. The return value will be a record number under dBase or a RecID under SQL. You may pass NULL as the third parameter if you do not want the RecNo/RecID.

Returns: >0 RecNo (dBase) or RecID (SQL) of matching record

0 No match found
GMW_DB_Seek

Positions to the first record matching the seek value. You should use GMW_DB_SetOrder prior to using this function.


Syntax: GMW_DB_Seek(long lWorkArea, char * szParam)
Parameters: The work area handle of the file opened by the GMW_DB_Open function.

The value you will seek. This value must match the format of the index expression for the currently active index.
Returns: 2 Exact match not found. Cursor placed at closest match

  1. Exact match found

0 No match or Error occurred
GMW_DB_SetOrder

Sets the current index on the table.


Syntax: GMW_DB_SetOrder( , )
Parameters: The work area handle of the file opened by the GMW_DB_Open function.

The name of the index to activate on the table. For a list of index names, see “Database Structures” in the GoldMine Reference Manuals or help file.
Returns: 1 Index successfully activated

0 Error
Navigating the database

These function will allow you to move to different records in the database. Most of the functions in this section will respect any scope limits placed on the table by the GMW_DB_Filter or GMW_DB_range functions.
GMW_DB_Move

Positions the record pointer to a particular record in a data file. This function accepts several commands. Each of these commands has an independent function equivalent that is the preferred method to use. This function remains as a legacy to its DDE counterpart:




Command

Parameter

Preferred Function Equivalents

TOP

Not required

GMW_DB_Top

BOTTOM

Not required

GMW_DB_Bottom

SKIP

number of records to skip

GMW_DB_Skip

GOTO

Record Number/RecID

GMW_DB_Goto

SEEK

Search key value

GMW_DB_Seek

SETORDER

Index name

GMW_DB_SetOrder

Syntax: GMW_DB_Move( <lWorkArea>, <szCommand>, <szParam> )


Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

Tthe command to execute.

<szParam> The scope or value for the command.
Returns: 4 Cursor at beginning of file (BOF)

3 Cursor at end of file (EOF)



  1. Exact match not found. Cursor placed at closest match.

  1. Exact match found, Cursor moved, or index successfully activated

0 Error

GMW_DB_Goto

Positions to a specific record in the table.
Syntax: GMW_DB_Goto( <lWorkArea>, <szRecNo> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

Specifies where the cursor should be placed, and is either RecNo (dBase) or RecID (SQL)

Returns: 4 Cursor at beginning of file (BOF)

3 Cursor at end of file (EOF)

2 Exact match not found. Cursor placed at closest match.

1 Exact match found, Cursor moved, or index successfully activated

0 Error
GMW_DB_Top

Positions to the first record in the table.
Syntax: GMW_DB_Top( <lWorkArea> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.
Returns: 1 Success. Cursor placed at first record


  1. Failure

GMW_DB_Skip

Moves the cursor forward or back in the table.
Syntax: GMW_DB_Skip( <lWorkArea>, <nSkip> )
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.

<nSkip> Specifies the number records to skip. This value can be positive to move forward in the table or negative to move backwards.
Returns: 4 Cursor at beginning of file (BOF)

3 Cursor at end of file (EOF)

1 Exact match found, Cursor moved, or index successfully activated

0 Error


GMW_DB_Bottom

Positions to the last record in the table.


Syntax: GMW_DB_Bottom( <lWorkArea>)
Parameters: <lWorkArea> The work area handle of the file opened by the GMW_DB_Open function.
Returns: 1 Cursor positioned at the last record in the file

0 Error


Quick Functions

The functions in this section are wrappers for the various other low-level functions. They are provided as a quick and easy way to perform common tasks. Be aware that although the functions are named “Quick” it is meant in the context of convenience and not speed of operation. When used in a single instance these functions are just as fast as the low-level function however, when used in loops these function perform more slowly. The reason is because these function each open/close their own work areas each time they are called.


GMW_DB_QuickSeek

This function will wrap several other DB functions to provide a quick and easy way to seek a record in the database.


Syntax: GMW_DB_QuickSeek(char *szTableName, char *szIndex, char *szSeekValue, char *szRecID)
Parameters: <szTableName> The name of the table to be opened.

<szIndex> The index to use for the table.

<szSeekValue> The seek expression to use.

<szRecID> Returned by the function. This will be the RecID of the record that is found.
Returns: 1 Success

  1. Failure

-1 Invalid table

-2 Invalid Index


GMW_DB_QuickRead

This function will wrap several other DB functions to provide a quick and easy way to read a field value from record in the database.


Syntax: GMW_DB_QuickRead( <szTableName>, <szRecID>, <szField>, <szValue>, <iLen> )
Parameters: <szTableName> The name of the table to be opened.

<szRecID> The RecID of the record to read from.

<szField> The Field name to return.

<szValue> The value returned by the function.

<iLen> The length of the returned data.
Returns: 1 Success

  1. Failure

-1 Invalid Table

-2 Invalid RecID

-3 RecID not found

-4 Invalid Fieldname


GMW_DB_QuickReplace

This function will wrap several other DB functions to provide a quick and easy way to replace a field value from record in the database.


Syntax: GMW_DB_QuickReplace( <szTableName>, <szRecID>, <szField>, <szValue>, <iAddTo>)
Parameters: <szTableName> The name of the table to be opened.

<szRecID> The RecID of the record to be updated.

<szField> The Field name to replace.

<szValue> The value to store in the field.

<iAddTo> Indicates if the value data is to be appended (1) or replaced (0=default).
Returns: 1 Success

  1. Failure

-1 invalid table

-2 Invalid RecID

-3 RecID Not Found

-4 Invalid Fieldname


GM5S32.DLL - Updating Sync Logs

GoldMine’s GM5S32.DLL offers developers a method to update the GoldMine synchronization logs whenever an external application updates GoldMine data outside of the GM5S32.DLL or GM5 COM object functions.
GMW_UpdateSyncLog

GMW_LoadBDE must be called before calling GMW_UpdateSyncLog for the first time.

When updating multiple fields of the same record, GMW_UpdateSyncLog must be called for each modified field. However, if the first call returns 1 or 2, it is not necessary to call GMW_UpdateSyncLog for the rest of the modified fields for that specific record.
Syntax: GMW_UpdateSyncLog( <szTable>, <szRecID>, <szField>, <szAction> )
Parameters: <szTable> Specifies the table name (such as “Contact1”) or the Table ID

<szRecID> Specifies the RecID of the updated record: the correct RecID must be passed, and the RecID value must be exactly 15 characters long.

<szField> Specifies the name of the field that has changed. This parameter is only relevant when the Action parameter is U. szField is ignored when szAction is N or D.

Should be N when a new record has been appended, D when a record has been deleted, or U when a field in a record has been updated.
Returns: 32 New Tlog Entry removed


  1. Deleted Tlog Entry

  1. Field Tlog entry updated

4 Field Tlog entry created

2 New Tlog entry update

1 New Tlog entry created

0 Failure


GMW_ReadImpTLog

GMW_LoadBDE must be called before calling GMW_ReadImpTLog for the first time. GMW_ReadImpTLog is executed in a thread, so multiple calls can be made. Your application can determine when the imported process completes by setting the iDeleteWhenDone parameter to 1, and noting when the import file is deleted. The TLog import must have the structure shown below:




Field Name

Type

Length

Table ID

char

10

RecID

char

15

Field ID

char

10

Action ID

char

1

Syntax: GMW_ReadImpTLog( <szFile>, <bDelDone>, <szStatus> )


Parameters: <szFile> Specifies the import file name.

<bDelDone> Specifies to delete the import file when the process has completed.

<szStatus> Buffer used to monitor the status of the process. Optional, can be NULL. If passed, the szStatus buffer must be at least 10 characters long.
Returns: >0 Success. Total number of imported Tlog records.

  1. Failure

GMW_NewRecID

GMW_NewRecID returns a new RecID in the szRecIDBuf. GMW_NewRecID can be called without first calling GMW_LoadBDE.
Syntax: GMW_NewRecID( <szRecIDBuf>, <szUser> )
Parameters: <szRecID> Specifies the application allocated buffer to contain the new RecID. The buffer must be at least 16 characters long.

<szUser> Specifies the GoldMine user name.
Returns: pointer to szRecIDBuf

GMW_SyncStamp

Converts Sync Stamp to time format and back.
Syntax: GMW_SyncStamp( <szStamp>, <szOutBuf> )
Parameters: <szStamp> When this string parameter is exactly 17 characters long, formatted as Date:Time in the form of CCYYMMDD:HH:MM:SS, the return string in szOutBuf is in TLog timestamp format, exactly seven characters long. When the szStamp parameter is seven characters long formatted as a TLog timestamp, the return string in szOutBuf is formatted as CCYYMMDD:HH:MM:SS.

<szOutBuf> Result of function. An empty return string indicates an error.

Returns: 1 Success

0 Failure

GM5 COM Object

Introduction

The GoldMine COM API wraps the 'C' API (GM5S32.DLL) in order to simplify access to the Name/Value pair component of the GoldMine API as well as the low-level WorkArea API. All objects are exposed using dual interfaces, in order to make them accessible to both clients that support virtual table binding, and clients that only support Dispatch Table binding (such as VBScript or JScript).


This document describes the objects in the COM API and how to use them. For specific information about available Name/Value pairs, and the transactions that can be executed, refer to “Business Logic Methods”. For specific information about the low-level WorkArea API, refer to the section "GM5S32.DLL - Low Level Access using Work Areas"

The Object Model

Figure 1 - The GM COM API Object Model

Figure 1 shows the objects in the model, together with their methods and properties. Not all of these objects are visible to the Visual Basic/Visual Basic Scripting Edition/ or Java Script client. The two enumerator objects are present to support Visual Basic’s For Each syntax.


A brief summary of the model is in order at this point. Only the top level object (GMApplication) is directly creatable by the client. This object encapsulates the functionality required to manage logins and logouts. The client would create an instance of this object, set its properties, and call Login. After a successful login, the client would then call NewContainer to create a new Name Value pair container. This would return an instance of the GMWContainer class. The container class exhibits standard COM

Collection semantics. It supports methods to allow the client to add name/value pairs, remove them, and get them by name. It also supports an enumerator that allows enumeration through all the pairs on a specific container. The use of default methods allows VB(Script) and JavaScript clients a simplified syntax for accessing the object. This will be expanded on in the specific documentation on the Container object.


When a client adds a new Name/Value pair, a GMNVPair object is returned. This can in turn behave as a collection of values, since it is possible to have single of multiple valued NV Pairs. Once again, the use of default methods simplifies the client programming model.
To Use the WorkArea API, the developer would call NewWorkArea on the Application object, which is the equivalent of the GMW_DB_Open function on the ‘C’ API. Thereafter the methods on the WorkArea class will act on the WorkArea (or table) that was opened, to allow the developer to read and update this table.
All methods on all classes make use of standard COM error handling to indicate failure. In the event of a call failing, a failure HRESULT will be returned (a VB exception), and a standard COM ErrorInfo object will be used to provide rich error information. All Error codes are made available through the EGMErrors enumeration in the type library.
The Application class.

This is the entry point to the Object Model. The Application class is call GMApplication. It can be instantiated using the ProgId “GMCOMApi.Application”.






Download 465.93 Kb.

Share with your friends:
1   2   3   4




The database is protected by copyright ©ininet.org 2024
send message

    Main page