在Talend中获取TMSSqlRow的输出 [英] Get output of TMSSqlRow in Talend
问题描述
我想获取受TMSSqlRow影响/删除/更新的行数.
I would like to get the number of row affected / deleted / updated with a TMSSqlRow.
工作内容如下:
文件使用包含很多SQL语句,例如DELETE ... INSERT ... UPDATE ... 每行用;"分隔
the file use contains a lot of sql statement like DELETE ... INSERT ... UPDATE... each row are separate by ";"
但是,现在,我想获取每个语句的结果(更新了x行,就像在Management Studio中显示了结果一样.)
But now, I would like to get result of each statement (x rows updated, like results are display in management studio).
当我转到tmssqlrow的高级设置"选项卡时,选择传播查询的记录集",然后选择我之前创建的列(对象类型).
When I go to "advanced settings" tab of tmssqlrow, I select " Propagate QUERY's recordset" and select a column I created before (Object Type).
执行时,出现此错误:
executeQuery方法必须返回结果集.
The executeQuery method must return a result set.
那么,如何获取每个语句的结果并将其插入(例如)到数据库/文件中?
So, how I can get the result of each statement and insert it (by example) in a database / file?
推荐答案
选项传播查询的记录集"必须与tParseRecordSet结合使用,以便从返回的记录集中提取信息.但是,这还不够:您必须显式编写查询以返回更新/删除的记录数.
The option "Propagate QUERY's recordset" must be used in combination with a tParseRecordSet in order to extract info from the returned recordset. However, that is not sufficent: you must explicitly write the query to return the number of records updated/deleted.
这就是我所做的:
我的tJDBCRow(与tMSSqlRow相同)查询看起来像这样(注意在更新查询之前必须添加'set nocount on',然后在之后添加'select @@ rowcount')
My tJDBCRow (same as tMSSqlRow) query looks like this (notice how I had to add 'set nocount on' before the update query, and 'select @@rowcount' after)
tParseRecordSet从列结果集中检索行数(nbLines是我的行数的别名)
tParseRecordSet retrieves the number of lines from the column resultset (nbLines is the alias of my rowcount)
这篇关于在Talend中获取TMSSqlRow的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!