BULKRETRIVE_BULKSAVE

Embed Size (px)

Citation preview

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    1/14

    BulkRetrieve object

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    2/14

    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 thefilter 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 thenumber of round trips to the database and generally improves

    performance.

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    3/14

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    4/14

    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 retrieveany 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 orSetRootById 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 canoperate 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 theTraverseFromParent method to add a parent traversal query to the

    BulkRetrieve object.

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    5/14

    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.UserObjidmybulk.TraverseFromRoot 0, user2employee

    mybulk.RetrieveRecords

    SET emplist = mybulk.GetRecordList( 0 )

    IF emplist.Count > 0 ThenSET emprec = emplist.ItemByIndex ( 0 )

    Cobj_Emp.Fill emprec

    END IF

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    6/14

    TraverseFromParent Example

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

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    7/14

    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 = 0TO subclist.Count - 1

    SET subcirec = subclist . ItemByIndex( subcidx )

    idlist.AppendItem subcrec . GetField( id_number)

    NEXT

    NEXT

    END IF

    TraverseFromParent Example

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    8/14

    BulkRetrive object defines the following methods

    AppendFilter

    AppendSort

    Clear

    EntryCount

    GetRecordListGetRelatedRecordList

    Print

    RetrieveRecords

    SetRootById

    SetRootSimpleQuery

    TraverseFromParent

    TraverseFromRoot

    BulkRetrieve

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    9/14

    BULKSAVE OBJECT

    BulkSave

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    10/14

    The BulkSave object encapsulates a set of database updatesinto 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.

    What is Bulksave object?

    BulkSave

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    11/14

    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 Example

    BulkSave

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    12/14

    CancelRecordChangeRecord

    CountByType

    DeleteRecord

    DeleteRecordBy

    ID

    GetRecordByInd

    ex

    InsertRecord

    Print

    RelateRecords

    RelateRecordsFromID

    RelateRecordsFromToID d

    RelateRecordsToIDSave

    UnrelateRecords

    UpdateRecord

    Properties :Save_Aborted

    Methods

    BulkSave

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    13/14

    The CancelRecord method removes one record from the BulkSave object only (

    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 theBulkSave 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 orUpdateRecord methods. It allows

    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

  • 8/2/2019 BULKRETRIVE_BULKSAVE

    14/14

    GetRecordByIndex method returns the record in the BulkSave object that is

    associated with the index value you provide. (An index is automatically assigned torecords when they are placed into the BulkSave.)

    InsertRecord method is used to insert a new record into the database. This methodadds the specified record to the BulkSave object.

    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.

    UpdateRecord method is used if you want to overwrite an existing record in thedatabase 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 theInsertRecord method.

    BulkSave