Dataset example
execute ibeblock as begin --dataset must be based on existing table structure select * from mytable where (1 = 0) as dataset MyDataset; ibec_ds_Append(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 1); ibec_ds_setfield(MyDataset, 'DATA', 'One'); ibec_ds_Append(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 2); ibec_ds_setfield(MyDataset, 'DATA', 'Two'); ibec_ds_Append(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 3); ibec_ds_setfield(MyDataset, 'DATA', 'Three'); ibec_ds_Post(MyDataset); --Reverse ibec_ds_Last(MyDataset); while (not ibec_ds_Bof(MyDataset)) do begin var = ibec_ds_GetField(MyDataset, 'DATA'); ibec_ShowMessage(var); ibec_ds_Prior(MyDataset); end --Insert as first record ibec_ds_First(MyDataset); ibec_ds_Insert(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 4); ibec_ds_setfield(MyDataset, 'DATA', 'Four'); ibec_ds_Post(MyDataset); --Forward ibec_ds_First(MyDataset); while (not ibec_ds_Eof(MyDataset)) do begin var = ibec_ds_GetField(MyDataset, 'DATA'); ibec_ShowMessage(var); ibec_ds_Next(MyDataset); end --Append, but cancel ibec_ds_Append(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 5); ibec_ds_setfield(MyDataset, 'DATA', 'Five'); ibec_ds_Cancel(MyDataset); --Edit first record ibec_ds_First(MyDataset); ibec_ds_Edit(MyDataset); ibec_ds_setfield(MyDataset, 'ID', 6); ibec_ds_setfield(MyDataset, 'DATA', 'Six'); ibec_ds_Post(MyDataset); --Forward ibec_ds_First(MyDataset); while (not ibec_ds_Eof(MyDataset)) do begin var = ibec_ds_GetField(MyDataset, 'DATA'); ibec_ShowMessage(var); ibec_ds_Next(MyDataset); end --Delete first record ibec_ds_First(MyDataset); ibec_ds_Delete(MyDataset); --Forward ibec_ds_First(MyDataset); while (not ibec_ds_Eof(MyDataset)) do begin var = ibec_ds_GetField(MyDataset, 'DATA'); ibec_ShowMessage(var); ibec_ds_Next(MyDataset); end --Save to file ibec_ds_SaveToFile(MyDataset, 'd:\MyDataset.bin'); ibec_ds_Close(MyDataset); --Load from saved file --dataset must be based on existing table structure select * from mytable where (1 = 0) as dataset MyDataset; ibec_ds_LoadFromFile(MyDataset, 'd:\MyDataset.bin'); ibec_ds_First(MyDataset); while (not ibec_ds_Eof(MyDataset)) do begin var = ibec_ds_GetField(MyDataset, 'DATA'); ibec_ShowMessage(var); ibec_ds_Next(MyDataset); end close dataset MyDataset; end
back to top of page
<< | IBEBlock | >>