Oracle 8.1.7中有表AA有字段IDID用触发器做的自增益DataSet.Insert,DataSet.Fields[0].AsString := xxxxx;DataSet.Post后DataSet.FieldByName('ID').AsInteger的值总是0查阅Oracle Ole DB文档:DBPROP_SERVERDATAONINSERTServer Data on Insert Property
If DBPROP_SERVERDATAONINSERT (Server Data on Insert) is set to TRUE using OraOLEDB, the consumer can obtain defaults, sequences, and triggered column values from newly inserted and updated rows, if the insert and update operations are made through the rowset. Having DBPROP_SERVERDATAONINSERT set to TRUE may degrade performance for both insert and update executions using a rowset because OraOLEDB fetches row data from the database for the newly inserted and updated row. However, if DBPROP_SERVERDATAONINSERT is set to its default value of FALSE, only the explicitly provided values for insert and update operations get returned when column values are requested for those rows. If the base table from which the rowset was created does not contain any defaults, sequences, or triggers, it is highly recommended that DBPROP_SERVERDATAONINSERT retain its default value of FALSE. The DBPROP_SERVERDATAONINSERT property does not affect the performance of insert and update executions using the command object. 查阅MSDN
MSDN Home > MSDN Library > Data Access > Microsoft OLE DB > OLE DB Programmer's Reference > Part 5: Appendixes > Appendix C: OLE DB Properties > Properties (Alphabetical)
OLE DB Programmer's Reference DBPROP_SERVERDATAONINSERT
Property group: RowsetProperty set: DBPROPSET_ROWSETColumn? NType: VT_BOOLTypical R/W: R/WDescription: Server Data on InsertValue Meaning
VARIANT_TRUE After an insert is transmitted to the server (when IRowsetChange::InsertRow is called in immediate mode or when IRowsetUpdate::Update is called for an inserted row in deferred update mode), the consumer can call IRowset::GetData to retrieve the actual values that appeared in the data store, including calculated columns and defaults not explicitly set in the call to IRowsetChange::InsertRow.
VARIANT_FALSE The provider does not retrieve values from the data store for newly inserted rows. The consumer can retrieve only data values explicitly set in the call to IRowsetChange::InsertRow or by calls to IRowsetChange::SetData for the hRow returned by InsertRow. Consumers should be aware that setting DBPROP_SERVERDATAONINSERT is potentially expensive and may not be supported for certain types of rowsets.
如何使用这个属性?试过DataSet.properties['DBPROP_SERVERDATAONINSERT'].value := true;报错...请高手帮忙解决....
If DBPROP_SERVERDATAONINSERT (Server Data on Insert) is set to TRUE using OraOLEDB, the consumer can obtain defaults, sequences, and triggered column values from newly inserted and updated rows, if the insert and update operations are made through the rowset. Having DBPROP_SERVERDATAONINSERT set to TRUE may degrade performance for both insert and update executions using a rowset because OraOLEDB fetches row data from the database for the newly inserted and updated row. However, if DBPROP_SERVERDATAONINSERT is set to its default value of FALSE, only the explicitly provided values for insert and update operations get returned when column values are requested for those rows. If the base table from which the rowset was created does not contain any defaults, sequences, or triggers, it is highly recommended that DBPROP_SERVERDATAONINSERT retain its default value of FALSE. The DBPROP_SERVERDATAONINSERT property does not affect the performance of insert and update executions using the command object. 查阅MSDN
MSDN Home > MSDN Library > Data Access > Microsoft OLE DB > OLE DB Programmer's Reference > Part 5: Appendixes > Appendix C: OLE DB Properties > Properties (Alphabetical)
OLE DB Programmer's Reference DBPROP_SERVERDATAONINSERT
Property group: RowsetProperty set: DBPROPSET_ROWSETColumn? NType: VT_BOOLTypical R/W: R/WDescription: Server Data on InsertValue Meaning
VARIANT_TRUE After an insert is transmitted to the server (when IRowsetChange::InsertRow is called in immediate mode or when IRowsetUpdate::Update is called for an inserted row in deferred update mode), the consumer can call IRowset::GetData to retrieve the actual values that appeared in the data store, including calculated columns and defaults not explicitly set in the call to IRowsetChange::InsertRow.
VARIANT_FALSE The provider does not retrieve values from the data store for newly inserted rows. The consumer can retrieve only data values explicitly set in the call to IRowsetChange::InsertRow or by calls to IRowsetChange::SetData for the hRow returned by InsertRow. Consumers should be aware that setting DBPROP_SERVERDATAONINSERT is potentially expensive and may not be supported for certain types of rowsets.
如何使用这个属性?试过DataSet.properties['DBPROP_SERVERDATAONINSERT'].value := true;报错...请高手帮忙解决....
怎么用没搞明白大家可以帮我看看这篇文章,里面有C++的用法...http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q219/0/29.asp&NoWebContent=1相关MSDN资料:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/oledbstartpage1.asp
2 properties是只读属性,不能赋值
3 对于序列号和流水号等的插入,由于并发性比较强,可以用存储过程,返回插入后的id,或者错误码(<0)的办法
2 你试试将properties中的
第0项 IAccessor:=True
第1项 IChapteredRowset:=True
第10项 IRowsetChange:=True
第13项 IRowsetIdentity:=True
Consumers should be aware that setting DBPROP_SERVERDATAONINSERT is potentially expensive and may not be supported for certain types of rowsets
另外 Oracle 的触发器不能返回任何东西,建议使用一个存储过程返回需要的ID,否则使用 Refresh 刷新。
ADODataSet.RecordSet.Resync()可以刷新RecordSet对象中的数据,可以选择只更新当前纪录。具体调用参数可以参见MSDN中ADO文档的RecordSet对象的ReSync方法。参数已经作为常数定义在Adoint单元中。 在实际使用中,可以从TADODataSet继承新类,重写InternalPost方法,加一句RecordSet.Resync()就可以了。 这样就可以保证在post数据之后将RecordSet中的数据与oracle同步,这个方法对SQL Server的默认值等同样有效。对性能有影响(重新取回数据)但不大(只在Post数据的时候同步当前行)。