Announcement

Collapse
No announcement yet.

Cached query returning rowset v text

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cached query returning rowset v text

    I am getting this back com.mirth.connect.server.userutil.MirthCachedRowSe [email protected]

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

  • #2
    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!

    Comment


    • #3
      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

      Comment


      • #4
        Originally posted by mroberts View Post
        I am getting this back com.mirth.connect.server.userutil.MirthCachedRowSe [email protected]
        ...
        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.

        Comment


        • #5
          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

          Comment


          • #6
            Let me close this as I think I got off on a tanget
            Last edited by mroberts; 05-01-2018, 05:21 AM. Reason: closing

            Comment


            • #7
              Did you figure it out? I have no idea why you got that ArrayIndexOutOfBoundsException

              Comment


              • #8
                No ideal

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

                Comment

                Working...
                X