javasql-server-2012mirth

Why is this string: javax.sql.rowset.serial.SerialClob being included in an output file instead of the actual value


I am using Mirth 3.1.0.x, to extract data from a Sql Server 2012 database and write the resultset to a flat file.

The code was working prior to a new column being added.

Here is the code in a transformer script for a Mirth Channel destination:

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();

In the file out, the last column is not being populated by the actual value but the following string:

"copay"

"javax.sql.rowset.serial.SerialClob@1b795929"

"javax.sql.rowset.serial.SerialClob@5693cfb7"

Below, is the T-SQL for the last column:

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

Solution

  • Changed cast from varchar(max) to varchar(20) and the actual column value is shown by the sql below. Found the answer thanks to Evan Knowles and 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