Is there any downside to passing a recordset to functions instead of individual variables?

后端 未结 1 660
醉酒成梦
醉酒成梦 2021-01-24 03:44

We have a single-user Access 2007 database that does things like send reports and update other databases on a timer (\"events\") -- one event at a time. As each event is execute

相关标签:
1条回答
  • 2021-01-24 04:17

    Short Answer

    In the exposed context, there is no downside to passing the recordset (as reference) to functions. This can be a good or bad thing depending on your overall design, product cycle, etc.

    Analysis

    • memory allocation : the Recordset object will be allocated for a longer time ; but will not use more memory. So no downside.
    • speed : As you won't have to copy the data from the recordset to variables, this could be an improvement - if working with big data amount, such as arrays.
    • locking the database : if no concurrent processes, there is no possible conflict. With concurrent processes, there is no conflict as long as Recordset are readonly.
    • data consistency (what happens if the database contents change while a Recordset is open) ? Data consistency is ensured by the DBMS. Depending if you want the changes to be reflected in the Recordset or not, open it as dynaset or snapshot (see also MSDN). To keep same behavior as now, it should be snapshot type.
    • interface design : The API of your functions would be more flexible - less sensitive to changes in the DB structure. Telling if this is a good thing or a downside ... well, is context-dependant and opinion-based.
    0 讨论(0)
提交回复
热议问题