如何(部分)自动将 FileMaker 数据库结构和字段内容传输到第二个数据库?
我正在尝试将一些字段值复制到重复的数据库中。一次记录一个。这用于历史记录,因此我可以删除原始数据库中的一些记录以保持快速。
我不想手动将值保存在变量中,因为有数百个字段。所以我想转到第一个字段,保存字段名称和值,然后转到另一个数据库并保存数据。然后运行“转到下一个字段”并循环遍历所有字段。
这工作得很好,但问题是:当字段是计算时,您无法使用 Tab 键进入它,因此“转到下一个字段”不起作用。它会跳过它。
我想过执行“转到对象”,但随后我需要命名所有对象,但找不到命名对象的脚本。
有人能想到解决办法吗?
谢谢!
I'm trying to copy some field values to a duplicate database. One record at a time. This is used for history and so I can delete some records in the original database to keep it fast.
I don't want to manually save the values in a variable because there are hundreds of fields. So I want to go to the first field, save the field name and value and then go over to the other database and save the data. Then run a 'Go to Next Field' and loop through all the fields.
This works perfectly, but here is the problem: When a field is a calculation you cannot tab into it and therefore 'Go to Next Field' doesn't work. It skips it.
I though of doing a 'Go to Object' but then I need to name all the objects and I can't find a script to name objects.
Can anyone out there think of a solution?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我总是发现导出/导入更容易的问题之一。
从一个数据库中导出所需的所有数据,然后将其导入到另一数据库中。您需要做的就是:
您甚至可以编写脚本来为您执行这些操作。
This is one of those problems where I always found it easier to do an export/import.
Export all the data you want from the one database, and then import it into the other database. All you need to do is:
You can even write a script to do these things for you.
有多种方法可以实现这一目标。
为了制作一个“历史档案”,我发现有几个案例,让我们看一下。
案例一
单个文件我只想“保留”一个包含历史数据的非常大的文件,因为我需要删除主文件中的所有数据。
在这种情况下,您应该创建一个“克隆”表(在同一文件或其他文件中,是相同的)。然后将任何计算字段更改为计算结果的类型(数字、文本、日期等...)。删除任何“从任何字段中自动输入的值或计算,例如自动编号、自动创建日期等...)。您将拥有一个没有计算或自动输入数据的“普通表”。
然后添加一个字段来控制重复数据。 必须创建一个...
如果您为每条记录都有一个发票编号(唯一),则可以执行此操作来完成此任务,但是如果您没有将记录标识为唯一的唯一字段,则 创建这样一个字段,我建议在克隆表上添加一个新字段并设置为输入计算并创建一个唯一的字段组合...如下所示:invoiceNumber & "-" & -“”&日期。
在克隆表上,请确保验证设置为“始终”,并且不允许有空值,并且该值是唯一的。
设置克隆表后...然后您可以导入记录,确保自动输入选项处于打开状态。您可以随意执行多次,新记录将被添加并且不会重复。
如果需要,可以编写一个脚本,在删除它们之前将所有当前记录移动到历史表中。
笔记:
当您尝试保留的数据不随时间变化时,此技术效果很好。这意味着,记录一旦创建就不会发生任何更改。
案例二
必须创建历史表,但更新某些字段。
一开始我以为历史数据永远不会改变。在某些情况下,我发现情况并非如此,例如我想跟踪历史发票,但同时跟踪它们是否已付款...
在这种情况下,您可以使用上面相同的技术,但相反导入数据...您必须根据标识记录的“唯一”字段更新数据。
希望这项技术有帮助
There are several ways to achieve this.
To make a "history file", I have found there are several cases out there, so lets take a look.
CASE ONE
Single file I just want to "keep" a very large file with historical data, because I need to erease all data in my Main file.
In this case, you should create a "clone" table (in the same file ore in other file, is the same). Then change any calculation field to the type of the calculation result (number, text, date, an so on...). Remove any "auto entered value or calculation from any field, like auto number, auto creation date, etc..). You will have a "Plain Table" with no calculations or auto entered data.
Then add a field to control duplicate data. If you have lets say an invoice number (unique) for each record, you can do this to achieve this task. But if you do not have a unique field that identifies the record as unique, then you have to create one...
To create such a field, I recommed to add a new field on the clone table and set as an aunto entered calculation and make a field combination that is unique... somthing like this: invoiceNumber & "-" & lineNumber & "-" " & date.
On the clone table make shure that validation is set up for "always", and no empty values allowed and that this value is unique.
Once you setup the clone table... then you can import your records, making sure that the auto enty option is on. Yo can do it as many times as you like, new records will be added and no duplicates.
If you want, can make a Script to do the move to historical table all the current records before deleting them.
NOTE:
This technique works fine when the data you try to keep do not have changes over time. This means, once the record is created is has no changes.
CASE TWO
A historical table must be created but some fields are updated.
In the beginnig I thougth a historical data, never changes. In some cases I found this is not the case, like the case I want to track historical invoices but at the same time, keep track if they are paid or not...
In this case you may use the same technique above, but instead of importing data... you must update data based on the "unique" fields that identifiy the record.
Hope this technique helps
FileMaker 的 FieldNames() 函数与 GetField() 一起可以为您提供字段名称列表及其值
FileMaker's FieldNames() function, along with GetField() can give you a list of field names and then their values