Sie sind auf Seite 1von 14

BulkRetrieve

BulkRetrieve object

BulkRetrieve

What is a BulkRetrieve Object? The BulkRetrieve object retrieves records from database tables and views. You use this method to search the database for records that match the filter criteria you specify.and records sorted according to the sort criteria you specify. You can use the BulkRetrieve object to perform multiple queries simultaneously.Grouping queries together reduces the number of round trips to the database and generally improves performance.

BulkRetrieve

BulkRetrieve The BulkRetrieve object supports three types of queries: A simple query retrieves records from a single database table or view. The query returns the records only in the specified table or view. It does not retrieve any related records. Use the SimpleQuery method to add a simple query to the BulkRetrieveobject. A root traversal query searches a relation of a specified record. The query returns any records that are linked to the root record through the specified relation. Use the SetRoot or SetRootById methods to specify the root record. Use the TraverseFromRoot method to add a root traversal query to the BulkRetrieve object. A parent traversal query is similar to a root traversal query except that it can operate on more than one root record. This query type uses an existing query to specify one or more root records. For each root record, the query retrieves the list of records that are linked to the root record through the specified relation. Use the TraverseFromParent method to add a parent traversal query to the BulkRetrieve object.

BulkRetrieve

TraverseFromRoot Example
To Read the employee record associated with the current user

DIM mybulk As New BulkRetrieve DIM emprec As Record DIM emplist As List mybulk.SetRootByID user,App.UserObjid mybulk.TraverseFromRoot 0, user2employee mybulk.RetrieveRecords SET emplist = mybulk.GetRecordList( 0 ) IF emplist.Count > 0 Then SET emprec = emplist.ItemByIndex ( 0 ) Cobj_Emp.Fill emprec END IF

BulkRetrieve

TraverseFromParent Example
To read the cases raised from site 101, and all their subcases DIM mybulk AS NEW BulkRetrieve DIM sitelist AS List DIM caselist AS List DIM subcaselist AS List DIM idlist AS NEW List DIM siterec AS Record DIM casered AS Record DIM subcrec AS Record DIM caseidx AS Integer DIM subcidx AS Integer mybulk.SimpleQuery 0, site mybulk.AppendFilter 0, site_id, cbequal, 101 mybulk.TraverseFromParent 1, cust_loc2case, 0 mybulk.TraverseFromParent 2, case2subcase, 1 mybulk.RetrieveRecords execute the transaction

BulkRetrieve

TraverseFromParent Example
SET sitelist = mybulk.GetRecordList ( 0 ) IF sitelist.count > 0 Then SET siterec = sitelist . ItemByIndex( 0 ) SET caselist = mybulk . GetRelatedRecordList ( siterec, cust_loc2case) FOR caseidx = 0 TO caselist.Count - 1 SET caserec = caselist . ItemByIndex ( caseidx ) SET subclist = mybulk . GetRelatedRecordList (caserec, case2subcase) idlist.ItemType = String FOR subcidx = 0 TO subclist.Count - 1 SET subcirec = subclist . ItemByIndex( subcidx ) idlist.AppendItem subcrec . GetField( id_number) NEXT NEXT END IF

BulkRetrieve

BulkRetrive object defines the following methods AppendFilter AppendSort Clear EntryCount GetRecordList GetRelatedRecordList Print RetrieveRecords SetRootById SetRoot SimpleQuery TraverseFromParent TraverseFromRoot

BulkSave

BULKSAVE OBJECT

BulkSave

What is Bulksave object? The BulkSave object encapsulates a set of database updates into one database operation. You can use this object to perform the following database operations: Add new records Change the data in existing records Delete records Add relations to a record Delete relations from a record This object complements the BulkRetrieve object, which read information from the database. You may use the BulkSave object in conjunction with these other objects to modify or delete existing records.

BulkSave

BulkSave Example A Record is being built in memory and inserted into the database DIM mybulk AS NEW BulkSave DIM conrec AS NEW Record set record variable to type contract conrec . RecordType = contract conrec . SetField id, C1002-34 set id field value conrec . SetField type, Platinum set type field value mybulk . InsertRecord conrec assigns objid mybulk . Save execute the transaction

BulkSave

Methods CancelRecord ChangeRecord CountByType DeleteRecord DeleteRecordBy ID GetRecordByInd ex InsertRecord Properties : Save_Aborted

Print RelateRecords RelateRecordsFromID RelateRecordsFromToID d RelateRecordsToID Save UnrelateRecords UpdateRecord

BulkSave

The CancelRecord method removes one record from the BulkSave object only (no from the database) and is used prior to the Save method or in the Form_Save callback. It does not affect records in the database. After you remove a record from the BulkSave object, that record is not saved to the database when you use the Save method.

The ChangeRecord method updates a record that was previously placed in the BulkSave object by the InsertRecord or UpdateRecord methods. It allows yo to make changes to BulkSave records prior to the execution of the Save method or in the Form_Save callback. The DeleteRecord method is used to delete a record in the database. However, the record you specify with the DeleteRecord method is not actually deleted from the database until the Save method is executed. Notice that DeleteRecord automatically removes relations to the deleted record.

BulkSave

GetRecordByIndex method returns the record in the BulkSave object that is associated with the index value you provide. (An index is automatically assigned to records when they are placed into the BulkSave.) InsertRecord method is used to insert a new record into the database. This method adds the specified record to the BulkSave object. UpdateRecord method is used if you want to overwrite an existing record in the database with a version of the record that is modified locally. This method works only on records that were retrieved from the database and modified locally. If you want to save a new record that you created, use the InsertRecord method. RelateRecords method is used to create a relation between two specified records. The records you want to relate must be already in a BulkSave object. The new relation is saved into the database along with the records when the Save method is performed on theBulkSave object. Save method commits the records and relations contained in the BulkSave object to database.

Das könnte Ihnen auch gefallen