为什么这个字符串:javax.sql.rowset.serial.SerialClob包含在输出文件中而不是实际值中

时间:2015-04-13 14:16:23

标签: java sql-server-2012 mirth

我正在使用Mirth 3.1.0.x,从Sql Server 2012数据库中提取数据并将结果集写入平面文件。

代码在添加新列之前正在运行。

以下是Mirth频道目的地的变换器脚本中的代码:

var dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sqlserver://10.10.1.74:1433/rRIS_California','rRIS_California','rRIS_California');    
var result1 = dbConn.executeCachedQuery("exec [z_SelectChannelData] 'AAI'");   

while(result1.next())
{         
   tmp.row += <row>
                      <LastName>"{result1.getString('LastName')}"</LastName>
                      <FirstName>"{result1.getString('FirstName')}"</FirstName>
                      <HomePhone>"{result1.getString('HomePhone')}"</HomePhone>
                      <MRN>"{result1.getString('MRN')}"</MRN>
                      <EncounterID>"{result1.getString('EncounterID')}"</EncounterID>
                      <Accession>"{result1.getString('Accession')}"</Accession>
                      <Modality>"{result1.getString('Modality')}"</Modality>
                      <Procedure>"{result1.getString('ProcedureCode')}"</Procedure>
                      <Location>"{result1.getString('Location')}"</Location>                         
                      <PreferredLanguage>"{result1.getString('PreferredLanguage')}"</PreferredLanguage>
                      <Gender>"{result1.getString('Gender')}"</Gender>
                      <EmailAddress>"{result1.getString('EmailAddress')}"</EmailAddress>
                      <MobilePhoneNumber>"{result1.getString('MobilePhoneNumber')}"</MobilePhoneNumber>
                      <Room>"{result1.getString('Room')}"</Room>                                  
                      <billing_code>"{result1.getString('billing_code')}"</billing_code>
                      <copay>"{result1.getString('copay')}"</copay>
                 </row>; 
}    
dbConn.close();

在文件输出中,最后一列没有填充实际值,而是填充以下字符串:

“共付”

“javax.sql.rowset.serial.SerialClob@1b795929”

“javax.sql.rowset.serial.SerialClob@5693cfb7”

下面是最后一列的T-SQL:

Select    
CASE WHEN v.copay is null THEN '' WHEN v.copay =0 THEN '' ELSE cast(v.copay as varchar(max)) END as copay
FROM <table> as v

2 个答案:

答案 0 :(得分:2)

将varchar(max)的强制转换更改为varchar(20),实际的列值由下面的sql显示。感谢Evan Knowles和kucing_terbang找到答案。

SELECT
CASE WHEN v.copay is null THEN '' WHEN v.copay =0 THEN '' ELSE cast(v.copay as varchar(20)) END as copay
FROM <table> v

答案 1 :(得分:1)

您可以尝试这样的事情。

var clob = result1.getClob("copay");
var result = clob.getSubString(1,clob.length());

然后将结果放在copay标记内。