如何在While语句中选择要分配给变量的当前记录数据。 [英] How do you select current record data to assign to variable in While statement.

查看:59
本文介绍了如何在While语句中选择要分配给变量的当前记录数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在while语句中分配临时变量。我知道第30行是错误的Where MachineName = MachineName ....。但是如果我在进入我的Select语句(第27行)之前就在记录251上,我如何将MachineName(已记录251)分配给我的变量?

I am trying to assign a temp variable in a while statement. I know row 30 is wrong "Where MachineName = MachineName ....". But if I''m on record 251 before I head into my Select statement (row 27) how do I assign MachineName(recored 251) to my variable?

展开 | 选择 | Wrap | 行号

推荐答案

你想做什么?您可能不需要这样做。你正在使用基于集合的RDBMS进行基于行的处理。


~~ CK
What are you trying to do? You might not need to do it this way. You''re doing a row based processing using a set-based RDBMS.


~~ CK


大图:

我们正试图在每台机器上使用OPC连接来跟踪工厂车间的生产情况。我们有一个数据记录器来提供MS SQL 2008 R2数据库,然后我尝试使用MS / Access作为最终用户的前端。


OPC将每隔3秒收集一次数据(看起来有点过分,但我们不希望操作员等待传输停机代码)。


我们对每台机器的生产,效率和停机时间(即过程监控)的按小时快照感兴趣。上面的代码是我第一次尝试在小时结束或发现停机代码发生变化时将数据汇总到一行数据。我一次走一行的原因是停机时间可能每小时发生2次或更多次,所以我必须查看正常运行代码与停机时间代码之间的中断点。如果有更好的方法,我会全力以赴。


每晚一次,会运行类似的代码将当天的汇总数据附加到历史文件中,每小时数据为只需要当天。详细数据仅保留当天。


我们希望向每台机器提供反馈,让操作员知道他们是否正在计划运行。并在单元格的末尾有一个屏幕,显示单元格中的每台机器如何实时进行。听起来像大哥一样,但我们确实试着专注于这个过程而不是大部分时间的操作员。


PS。我现在要处理的数据是来自数据记录软件的虚拟数据。这就是我用真实数据处理分钟与小时的原因。
Big Picture:
We are attempting to use an OPC connection on each machine to track production on the factory floor. We have a data logger to feed the MS SQL 2008 R2 database, and then I’m trying to use MS/Access as the front end for the end user.

OPC will be collecting data about every 3 seconds (seems like overkill, but we do not want to operator waiting around for a downtime code to be transmitted).

We are interested in a “by hour snapshot” of each machine’s production, efficiency and downtime, i.e. Process monitor. In the code above is my first attempt at summarizing the data down to one line of data when the hour is up or a change in the downtime code has been found. The reason I’m going one line at a time is down time could happen 2 or more times an hour, so I have to look where there is a break between the up-time code vs. the down-time code. If there is a better way, I’m all ears.

Once a night, similar code will be ran to append the summarized data for the day to the history file, hourly data is only needed for the current day. Detail data will only be kept for the current day.

Down the road we want feedback to each machine letting the operator know if they are running to plan or not. And have a screen at the end of the cell showing how each machine in the cell is doing in real time. Sounds like big brother watching, but we do try to focus on the process and not the operator most of the time.

PS. Data I''m dealing with now is dummy data from the data logging software. That’s why I’m dealing with minutes vs. hours with the real data.


什么是OPC?


~ ~CK
And what is an OPC?


~~ CK


这篇关于如何在While语句中选择要分配给变量的当前记录数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆