简体   繁体   English

XE6 TUniQuery使用SubSelect插入

[英]XE6 TUniQuery Insert Into with SubSelect

I working in a VCL project. 我在VCL项目中工作。 I'm populating a TUniQuery with a Insert that uses a sub select . 我正在使用带有sub selectInsert填充TUniQuery Looking at the MySQL log file, I can see the command is hitting the database. 查看MySQL日志文件,可以看到命令正在命中数据库。 There are no errors or exceptions being reported and everything seems to be executing properly. 没有错误或异常的报告,一切似乎都在正常执行。 When I query the database though, the data isn't there. 但是,当我查询数据库时,数据不存在。 If I copy and paste the command from the log file and run it in dbForge then it executes the command properly and populates the table. 如果我从日志文件复制并粘贴命令并在dbForge中运行它,则它将正确执行该命令并填充表。 Below is the code without the fields specified: 以下是未指定字段的代码:

UniQuery->Close();
UniQuery->SQL->Clear();
UniQuery->SQL->Add("INSERT INTO tmplegacypricingdistinct (...) ");
UniQuery->SQL->Add("SELECT DISTINCT ... FROM tmplegacypricing");
UniQuery->Execute();

I plan to make the tables used into temp tables, however they are currently real tables. 我计划将使用的表制作成临时表,但是目前它们是真实表。

Some thoughts I had were that it could be the connection, but since its being logged in the mysql log file I don't see that being the issue. 我曾以为它可能是连接,但由于将其记录在mysql日志文件中,所以我认为这不是问题。 I have a work around which would be to pull the information down then insert one record at a time, but I'd hate to pull the data over the wire and have to do that. 我有一个解决方法,就是将信息拉下来,然后一次插入一条记录,但是我不愿意通过网络拉数据,而必须这样做。 Thoughts or ideas on what I can do to make it all happen on the server's end or what my issue with the above approach could be? 关于如何使它全部发生在服务器端的想法或想法,或者上述方法的问题可能是什么?

Make sure that you don't have any TEMPORARY tables and REAL tables with the same name's. 确保您没有任何具有相同名称的TEMPORARY表和REAL表。 MySQL lets you do that. MySQL使您可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM