IBM i Global

IBM i Global

Connect, learn, share, and engage with IBM Power.

 View Only
  • 1.  Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Mon January 15, 2024 02:36 PM

    I have used the basic code from @Scott Forstie's gist to produce beautiful spreadsheets.  I need to confirm if any of you have tried to use this technique for a file in QTEMP.  Mine fail with file not found. Yes, I would prefer not using QTEMP, but much of the code I could retrofit uses QTEMP or the more up-to-date DECLARE GLOBAL TEMPORARY TABLE version. When I looked at a recent program, there was too much going in the SQLRPGLE to simply replace it with a single SQL.  I can live with this for some processes, but those where multiple users could be running the process at the same time benefit from QTEMP. 

    https://gist.github.com/forstie/cec5b0bf5c0e6983125ae078b0d04b48



    ------------------------------
    David Taylor
    Sr Application Developer
    Range Resources
    Fort Worth TX
    ------------------------------


  • 2.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Tue January 16, 2024 02:47 AM
    Edited by Satid Singkorapoom Tue January 16, 2024 06:52 AM

    Dear David

    As far as SQL SELECT from available physical files in QTEMP is concerned, it works. Only when you access large amount of data from there and also do additional features such as joining, group by, order by, etc. that you may encounter performance issue but this is relative to your server's HW performance capability and so it may or may not be serious. 

    When you said you could not find the files in QTEMP, how did you run Scott's code?  Did you run it from ACS's Run SQL Script session or from a 5250 interactive session or as a batch job?   How was your code that used QTEMP run, from ACS's Run SQL Script session or from a 5260 interactive session or as a batch job?  Does Scott's code run within the same program code as your old code?  If not, how does it run after QTEMP has the data available? 

    Assuming you want to only SELECT from a physical file in QTEMP (If not, please specify what else you do), SQL in IBM i can access objects in QTEMP but you need to ensure that you run Scott's code from the SAME JOB that also runs your old code that uses QTEMP, whether it is ACS's Run SQL Script or an interactive or batch job.  


    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 3.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Tue January 16, 2024 03:06 AM

    Hello David,

    Using QTEMP has always had it's limitations, a Global Temporary tables also uses QTEMP to store the table. When working with RSS/SQL maybe using QRPLOBJ helps you out. In order to create a unique table you can use the job number to use this in the name of the table. QRPLOBJ is cleared by default when you IPL the system, but adding a DROP IF EXISTS (https://www.ibm.com/docs/en/i/7.5?topic=object-drop-if-exists) in the SQL script used for mailing a spreadsheet, will avoid having duplicate names. In case you are running your system which does not IPL that often or when having a rapid speed of using the job numbers. 

    Anyway that is what I do to get over the limitations of QTEMP.

    I can only hope this helps you,

    Greetings, 



    ------------------------------
    Rudi Van Helvoirt
    ------------------------------



  • 4.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Tue January 16, 2024 09:26 AM

    Yes, I needed to have supplied more detail.  I am running from the STRSQL command line from a terminal session with the correct library list, including QTEMP. When I run the stored procedure with the query containing a standard library, the process completes and loads 17 rows to the spreadsheet. When I call the SP with the query for the QTEMP library, I get the error below. I can plan around this, but the model for the SP I am using stores the query in file.  I guess I could plan to load a unique record into the query reference file for each user and then ...... You can see why I would prefer to know that this is a limitation to the tool rather than an error in logic. 

      

    Transfer request is complete.                                                
    Transfer statistics: 00:00:07                                                
    Rows transferred: 17                                                         
    Press ENTER to end terminal session.                              

              
    MSGDB0036 - Server returned SQL error ([SQL0204] RVSX924PF in QTEMP type *FILE not found.)                                                                
    Press ENTER to end terminal session.                                         



    ------------------------------
    David Taylor
    Sr Application Developer
    Range Resources
    Fort Worth TX
    ------------------------------



  • 5.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Wed January 17, 2024 02:12 AM
    Edited by Satid Singkorapoom Wed January 17, 2024 05:12 AM

    Dear David

    I'm not familiar with a terminal session with the message "Press ENTER to end terminal session."   Is it a 5250 emulation session? I hope it is.  But then I'm not sure I understand what you meant by "the model for the SP I am using stores the query in file."

    Anyway, after encountering the error, would you run DSPLIB QTEMP from 5250 command line to confirm that the object RVSX924PF is in QTEMP?  If so, the best I can guess is that the stored procedure you run has its own job to run in other than the same 5250 session job that you run STRSQL. The message text " Server returned SQL error (...." makes me suspect this.  You need to look into the code of the SP to confirm this.  Or if possible, post the SP source code here so I can try looking into to confirm my suspicion.

    If the SP really runs in a new job, then a solution is to copy the data from QTEMP to a user library. 

    One last point, STRSQL has many limitation compared to Run SQL Script tool.  You should try running your program that produces the result into QTEMP and calling your SP from Run SQL Script tool to see if it works or not.  When you run CL in Run SQL Script session, you begin the line with CL:  and end each command line with semicolon (;) just like each SQL statement. 


    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 6.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Wed January 17, 2024 09:11 AM

    Satid, 

    That is a thought I had not considered, somehow the process has its own QTEMP.  I am going to run with that and stop worrying. Here is the very simple source modified from Scott's start. Since the SP requires the system name in the code, I will have two versions, one for the TEXTBOX and one for PROD.

    On a side note--and yes I should make this a separate thread--when I run the process, it leaves extra files on the system. Since this XLSX was written to /TMP, I need to test to see if the left-overs are always in /TMP or not.  The poifiles subfolder has data from previous runs as well. Do I need a clean-up as part of the process?  

     



    ------------------------------
    David Taylor
    Sr Application Developer
    Range Resources
    Fort Worth TX
    ------------------------------

    Attachment(s)

    TXT
    UTLXLSTSP.TXT   8 KB 1 version


  • 7.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Wed January 17, 2024 11:25 AM
    Edited by ac Wed January 17, 2024 11:27 AM

    Your are using ACS java client under the hood. So you are invoking ACS via QSH or RUNJVA or new SYSTOOLS.GENERATE_SPREADSHEET so basically I suppose no QTEMP "visibility" if another process is created to serve the ACS in a connection.

    /tmp should be a temporary area.

    But I agree, ACS shouldn't leave a POI leftover if not explicitly requested and returning successfully, a program should clean up its stuff.



    ------------------------------
    --ft
    ------------------------------



  • 8.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Wed January 17, 2024 07:33 PM
      |   view attached

    Dear David

    I agree with Ace Ace when I see STRQSH in your SP as it invokes a different thread of its own and should not see QTEMP of the 5250 session from which you invoke the SP.   The solution can be for you to copy whatever your want from QTEMP to a normal library before calling the SP that access the data from the normal library.   

    By the way, I'm not sure if you are aware of RUNSQL command which you can also use to call your SP as an alternative to STRSQL session which I do not like to use much as it has no enhancement for too long and is considered a fossil. I attach a number of articles by Bruce Vinning on RUNSQL in case you are interested to learn about it. 

    As for your last question, I have not much knowledge in Java environment to answer. You should ask it in a new post.  But from my limited experience, I did notice that Java app leaves strange-named files in IFS. 



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------

    Attachment(s)

    pdf
    CL-V6R1 RUNSQL command.pdf   530 KB 1 version


  • 9.  RE: Using the Spreadsheet Functions in ACS for QTEMP files.

    Posted Thu January 18, 2024 08:48 AM

    Thank you all for the valuable input. I was able to confirm what I needed to move forward. Case closed on this one.  



    ------------------------------
    David Taylor
    Sr Application Developer
    Range Resources
    Fort Worth TX
    ------------------------------