web stats
Cached query returning rowset v text - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2018, 12:52 PM
mroberts mroberts is offline
OBX.1 Kenobi
 
Join Date: Jul 2010
Posts: 40
mroberts is on a distinguished road
Default Cached query returning rowset v text

I am getting this back com.mirth.connect.server.userutil.MirthCachedRowSe t@47d071cd

Versus the text of the file name and path

SQL command works in sql manager and I have been reading the forum and I am sure I am just doing something wrong that is simple



var filenameandpath = dbConn.executeCachedQuery("select location+sub_location+file_name as source FROM page WHERE document_id = '" +$('document_id')+ "' and sequence_nbr = "+counter+" ");
filenameandpath.next();

channelMap.put('filename',filenameandpath.getStrin g(0).trim());

logger.info(filenameandpath);
channelMap.put("Filenameandpath",filenameandpath);
Reply With Quote
  #2  
Old 04-30-2018, 01:58 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

It would always return a CachedRowSet. You need to iterate over it with .next() to get data -


Code:
while(result.next()) {
patientFirstName=result.getString(name_of_the_coloumn);
}
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
  #3  
Old 04-30-2018, 04:58 AM
mroberts mroberts is offline
OBX.1 Kenobi
 
Join Date: Jul 2010
Posts: 40
mroberts is on a distinguished road
Default

Quote:
Originally Posted by siddharth View Post
It would always return a CachedRowSet. You need to iterate over it with .next() to get data -


Code:
while(result.next()) {
patientFirstName=result.getString(name_of_the_coloumn);
}
It should only return 1 row with only column not sure I understand why I need to iterate over it
Reply With Quote
  #4  
Old 04-30-2018, 06:16 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 894
agermano is on a distinguished road
Default

Quote:
Originally Posted by mroberts View Post
I am getting this back com.mirth.connect.server.userutil.MirthCachedRowSe t@47d071cd
...
logger.info(filenameandpath);
channelMap.put("Filenameandpath",filenameandpath);
filenameandpath is a CachedRowSet, so what you're getting back is expected for these two lines.

As far as
Code:
channelMap.put('filename',filenameandpath.getString(0).trim());
The column numbering starts at 1, not 0.
Reply With Quote
  #5  
Old 04-30-2018, 06:41 AM
mroberts mroberts is offline
OBX.1 Kenobi
 
Join Date: Jul 2010
Posts: 40
mroberts is on a distinguished road
Default return set

Okay I am dense today I guess I get this error. I am trying to map to the variable the string that is returned from the query. Query will only return 1 value. Thank you guys for trying to help i guess it is just not clicking for me today. What am i missing

532: //sql to get document and file location based on sequence numbers
533: var filenameandpath = dbConn.executeCachedQuery("select location+sub_location+file_name as source FROM page WHERE document_id = '" +$('document_id')+ "' and sequence_nbr = "+counter+" ");
534: filenameandpath.next();
535: channelMap.put('filenamedd',filenameandpath.getStr ing(1).trim());
536: logger.info(filenameandpath);
537: channelMap.put("Filenameandpath",filenameandpath);
538:
539:
LINE NUMBER: 535
DETAILS: Wrapped java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0

Get the above error

If I run sql command like below I get back 1 correct value like this
"\\fileserver2\storage1\2018\20180424\46E0D029-9B71-4902-AE37-1B7C200134AE.tif"

select location+sub_location+file_name as source FROM page WHERE (document_id = '6103471D-F40E-44A5-975C-09C1ED341D2E') and sequence_nbr = 1
Reply With Quote
  #6  
Old 05-01-2018, 05:19 AM
mroberts mroberts is offline
OBX.1 Kenobi
 
Join Date: Jul 2010
Posts: 40
mroberts is on a distinguished road
Default

Let me close this as I think I got off on a tanget

Last edited by mroberts; 05-01-2018 at 05:21 AM. Reason: closing
Reply With Quote
  #7  
Old 05-02-2018, 02:32 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 894
agermano is on a distinguished road
Default

Did you figure it out? I have no idea why you got that ArrayIndexOutOfBoundsException
Reply With Quote
  #8  
Old 05-07-2018, 10:50 AM
mroberts mroberts is offline
OBX.1 Kenobi
 
Join Date: Jul 2010
Posts: 40
mroberts is on a distinguished road
Default No ideal

No I did not figure it out. s Still working on getting a total row count from a sql call in java
Reply With Quote
Reply

Tags
java, rowset

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation