执行sql时插入? [英] When perform sql insert?

查看:82
本文介绍了执行sql时插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VCL TCPServer组件,每次在tcp端口上收到一个数据
时都会触发事件。在事件中,数据可用于文本
参数的过程。因为我想保存这个数据到mysql
数据库我想知道哪个是最好的方法来解决这个问题。
在每个收到的数据
的过程中直接使用INSERT SQL命令,或将数据存储在内存中(即TStrings),然后每X(使用Timer)分钟调用
a函数,分解INSERT命令?

I am using a VCL TCPServer components which fires events everytime a data is received on a tcp port. Within the event data is available into text parameter of the procedure. Because I want to save this data into mysql database I am wondering which is the best approach to this problem. Directly use an INSERT SQL command within the procedure for every data received or store the data in a memory (i.e. TStrings) and then calling a function every X (using Timer) minutes excute the INSERT command?

谢谢

Ok对不起,

推荐答案

这不是您的问题的真正答案,但请考虑您的应用程序在接收数据和执行 INSERT

It's not really an answer to your question, but do consider the risk of your application failing (for any reason) between receiving the data and executing the INSERT.

如果您使用某种本地存储作为中间件来减轻此风险,请考虑以下风险:该商店正在更新时崩溃。

If you use a local store of some kind as an intermediate to mitigate this risk, consider the risk of a crash while that store is being updated.

RDBMS供应商竭尽全力确保已成功完成 INSERT UPDATE 或类似的命令不会丢失或损坏。你可以投入类似的努力吗?

RDBMS vendors go to great lengths to ensure that data that has been accepted by successful completion of an INSERT, UPDATE or similar command will not be lost or corrupted. Can you put in similar effort?

一般来说,如果你接受数据零碎而不是批量,我可能会保持与数据库的开放连接并将数据插入您收到它,只有在推送到数据库后才向应用程序的消费者发送确认。

Generally speaking, if you are accepting data piecemeal rather than in bulk, I would probably keep an open connection to the database and insert data as you receive it, and only send an acknowledgement back to the consumer of your application once it has been pushed to the database.

这篇关于执行sql时插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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