Cognos Analytics

 View Only
  • 1.  Need to Run Stored Procedure Using Prompt Values

    IBM Champion
    Posted Thu May 30, 2024 09:03 PM

    I need help with a proof of concept that I swear I did once before but don't remember how I did it. Looking for some help.

    I have an Oracle table named TEST with one column (string) called NAME. I create a stored procedure to taking a string parameter named pNAME and inserting a record to the TEST table. I can run it all day from SQL Developer so I know the procedure works for Oracle.

    Now I want to put a text prompt on a Cognos prompt page using parameter ?Name? where I want the user to enter a string, click a button, and it executes the stored procedure to use the value for ?Name? to run the SP.  How do I get this to work?

    I've tried ways of calling the stored procedure in a Cognos SQL query without any luck.

     I've imported the SP to the framework as an SP query subject and switched it to Data Modification, added the macro to the parameter and tested it on the framework just fine. But when I publish the package I can never see the query subject of this SP appear. 

    Having a hard time figuring out how to make this POC work. If I could just get it to work I can take it the rest of the way, but I'm clearly missing something here about how SPs function in Cognos or how to wire them up.



    ------------------------------
    Logan Whitaker
    ------------------------------


  • 2.  RE: Need to Run Stored Procedure Using Prompt Values

    Posted Fri May 31, 2024 01:57 AM

    Hi,

    As far as I understand your description, it seems all correct to me. 

    Steps to check:

    1. SP works only with FM projects, that means that you have a CQM (32-bit Report server exécution mode available):
      1. Check that the QS works fine on FM
      2. When you create a new QS check that it have been added to the published pack
      3. Publish the pack and check on the web that the pack is correctly updated(same published date and place show in FM)
      4. Open the published pack with Report and check that the SP can be called from that

    Good luck

    German



    ------------------------------
    German Rodriguez
    ------------------------------



  • 3.  RE: Need to Run Stored Procedure Using Prompt Values

    IBM Champion
    Posted Fri May 31, 2024 04:24 AM

    Hi Logan,

    The best way to test a stored procedure (only user-defined stored procedures) is first, with Framework Manager.

    There are 2 types of stored procedures: Data Query (Issues a read-only transation) or Data Modification (Writes a record to the data source. Use this type when you want to use the stored procedure in Event Studio.)

    Here is a link to the documentation:

    https://www.ibm.com/docs/en/cognos-analytics/12.0.0?topic=subjects-creating-modifying-stored-procedure-query

    Best regards,



    ------------------------------
    Patrick Neveu
    Collaboration Betters The World (CBTW)
    IBM Champion
    ------------------------------



  • 4.  RE: Need to Run Stored Procedure Using Prompt Values

    IBM Champion
    Posted 29 days ago

    Thanks, Patrick.  The IBM documentation is infamous for being a bit high-level but I certainly did read what you sent.  The missing piece for my effort was having an OUT dataset in the SP so that when imported to the framework and published... there was something for the query to return even though the intent was to return nothing; only write a new record.  



    ------------------------------
    Logan Whitaker
    ------------------------------



  • 5.  RE: Need to Run Stored Procedure Using Prompt Values
    Best Answer

    IBM Champion
    Posted Fri May 31, 2024 04:28 AM

    Hi Logan,

    I also use STP to write back data into the DWH. The concept I use is to leave the STP in Framework Manager for "Data Queries", not for "Data Modification". The trick is to include a variable/parameter into your procedure that returns a value so Cognos can use it to display data. The procedure than appears in Cognos only with the returned column available and whenever you want to "see" its content, Cognos would have to send the appropriate parameters to the STP, runs it and returns the data.

    One of my simple procedures have the values: two as input and one as output (STATUS). Whenever the procedure is run, it returns a string called STATUS. Works fine.

    To achieve that I work with conditional blocks that check whether a parameter is filled or not.Otherwiese the procedure is run every time with the report itself.



    ------------------------------
    Robert Dostal
    Team Leader BI
    GEMÜ Gebr. Müller Apparatebau GmbH & Co. KG
    Ingelfingen
    ------------------------------



  • 6.  RE: Need to Run Stored Procedure Using Prompt Values

    IBM Champion
    Posted 29 days ago

    Thank you for the tips, Robert.  The clues about needing the query to return something (even if it's only writing data) along with using Data Queries allowed me to put some "OUT" parameter(s) in the stored procedure + import it to the framework using Data Queries and it worked for me.  



    ------------------------------
    Logan Whitaker
    ------------------------------



  • 7.  RE: Need to Run Stored Procedure Using Prompt Values

    Posted Fri May 31, 2024 09:45 AM

    There are quite a few youtube videos with "cognos stored procedure update" or "cognos stored procedure write" . I used primarily this one https://www.youtube.com/watch?v=00xaDWs5igo when i had a screen that allowed a Report's Yes/No toggle to update a SQL table. So mine was not a prompt value that updated and i had to redisplay my screen with the new toggle value. So slightly different than yours.



    ------------------------------
    brenda grossnickle
    BI Programmer Analyst
    FIS
    ------------------------------