DF_FILE_REFIND_AFTER_SAVE
Determines whether a record must be found again directly after saving it.
Level
Table
Supported by
The DataFlex SQL Drivers (SQL Server, DB2, and ODBC)
Type
Boolean, permanent
Access
Read / Write
Values
- True
- False
Syntax
Use cli.pkg
Get_Attribute DF_FILE_REFIND_AFTER_SAVE of {tableNumber} to {BooleanVariable}
Set_Attribute DF_FILE_REFIND_AFTER_SAVE of {tableNumber} to {True|False}
Remarks
If database triggers are defined on a table that fill one (or more) columns in a row that is created or updated, you may use this attribute if you want these new column values to be available directly after the save operation. Setting this attribute to true will ensure that the record buffer is up-to-date. Setting this attribute to false (the default) will switch re-fetching the row off. This eliminates a Client/Server communication roundtrip, thus speeding up performance when creating records.
This attribute can be set both inside and outside of a Structure_Start ... Structure_End operation. The value of the attribute is stored in the intermediate file using the keyword Refind_After_Save.
Example
Procedure CreateTable
Handle hTable
Handle hoWorkspace
String sPath
String sOrigFolder
Integer iColumn
Integer iIndex
//*** Make sure int file comes in first folder of datapath by
//*** making that folder current
Get phoWorkspace Of ghoApplication To hoWorkspace
Get psDataPath Of hoWorkspace To sPath
Get PathAtIndex Of hoWorkspace sPath 1 To sPath
Get_Current_Directory To sOrigFolder
Set_Directory sPath
//*** Create a SQL Server table to store clock in/out times
//*** of employees
Move 0 To hTable
Structure_Start hTable "MSSQLDRV"
Set_Attribute DF_FILE_PHYSICAL_NAME Of hTable To "RIMSample.int"
Set_Attribute DF_FILE_RECNUM_TABLE Of hTable To True
Set_Attribute DF_FILE_LOGIN Of hTable To "SERVER=(local);Trusted_Connection=yes;DATABASE=Northwind"
Set_Attribute DF_FILE_TABLE_NAME Of hTable To "RIMSample"
Set_Attribute DF_FILE_GENERATE_RECORD_ID_METHOD Of hTable To RIM_IDENTITY_COLUMN
Set_Attribute DF_FILE_PRIMARY_INDEX Of hTable To 0
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "ID"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_BCD
Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 4
Move 0 To iColumn
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "Name"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_ASCII
Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To 50
Move 0 To iColumn
Create_Field hTable At iColumn
Set_Attribute DF_FIELD_NAME Of hTable iColumn To "Comment"
Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_TEXT
Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To (5 * (2^20))
Move 0 To iIndex
Create_Index hTable At iIndex
Set_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To 1
Set_Attribute DF_INDEX_SEGMENT_FIELD Of hTable iIndex 1 To 1
Set_Attribute DF_INDEX_NAME Of hTable iIndex To "RimSample001"
Structure_End hTable
//*** Reset current working folder to original value
Set_Directory sOrigFolder
//*** Add to filelist and generate fd
Move 0 To hTable
Get_Attribute DF_FILE_NEXT_EMPTY Of hTable To hTable
If (hTable > 0) Begin
Set_Attribute DF_FILE_ROOT_NAME Of hTable To "MSSQLDRV:RIMSample"
Set_Attribute DF_FILE_DISPLAY_NAME Of hTable To "RIM sample table"
Set_Attribute DF_FILE_LOGICAL_NAME Of hTable To "RIMSamp"
Open hTable
Get psDDSRCPath Of hoWorkspace To sPath
Get PathAtIndex Of hoWorkspace sPath 1 To sPath
If (Right(sPath, 1) <> Sysconf(Sysconf_Dir_Separator)) ;
Move (sPath - Sysconf(Sysconf_Dir_Separator)) To sPath
Move (sPath - "RIMSamp.fd") To sPath
Output_Aux_File DF_AUX_FILE_FD For hTable To sPath
Close hTable
End
End_Procedure // CreateTable
Procedure BulkCreate
Integer iRecID
Boolean bRefind
Boolean bGetRID
DateTime dtBegin
DateTime dtEnd
TimeSpan tsFirst
TimeSpan tsSecond
Get_Attribute DF_FILE_REFIND_AFTER_SAVE Of RIMSamp.File_number To bRefind
Get_Attribute DF_FILE_GET_RID_AFTER_CREATE Of RIMSamp.File_number To bGetRID
Set_Attribute DF_FILE_REFIND_AFTER_SAVE Of RIMSamp.File_number To False
Set_Attribute DF_FILE_GET_RID_AFTER_CREATE Of RIMSamp.File_number To False
Move (CurrentDateTime()) To dtBegin
For iRecID From 1 To 1000
Begin_Transaction
Clear RIMSamp
Move iRecID To RIMSamp.Id
Move ("Name" - String(iRecID)) To RIMSamp.Name
SaveRecord RIMSamp
End_Transaction
Loop
Move (CurrentDateTime()) To dtEnd
Move (dtEnd - dtBegin) To tsFirst
Set_Attribute DF_FILE_REFIND_AFTER_SAVE Of RIMSamp.File_number To True
Set_Attribute DF_FILE_GET_RID_AFTER_CREATE Of RIMSamp.File_number To True
Move (CurrentDateTime()) To dtBegin
For iRecID From 1001 To 2000
Begin_Transaction
Clear RIMSamp
Move iRecID To RIMSamp.Id
Move ("Name" - String(iRecID)) To RIMSamp.Name
SaveRecord RIMSamp
End_Transaction
Loop
Move (CurrentDateTime()) To dtEnd
Move (dtEnd - dtBegin) To tsSecond
Set_Attribute DF_FILE_REFIND_AFTER_SAVE Of RIMSamp.File_number To bRefind
Set_Attribute DF_FILE_GET_RID_AFTER_CREATE Of RIMSamp.File_number To bGetRID
Showln "Creating 1000 records with attributes off takes " tsFirst
Showln "Creating 1000 records with attributes on takes " tsSecond
End_Procedure // BulkCreate
The sample procedure above creates 1000 records in the RIMSamp table with the "refind after save" and "get rid after create" settings off. After that, it creates 1000 records with the settings on. At the end, it displays the time both loops take. The procedure to create the RIMSamp table is also part of the sample code.