开发者

When perform sql insert?

I am using a VCL TCPServer components which fires events everytime a data is rec开发者_运维问答eived 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?

Thanks

Ok Sorry.


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜