Wednesday, August 27, 2014
   
Text Size
Login

SSRS Retrieving Oracle Stored Procedure Success or ErrorLevel

What?
We have a report in SQL Server Reporting Services 2008 R2 (SSRS) reading from an Oracle 10g database which works great and lists all the details on a specific student. An additional request is that there appears a link that will run a stored procedure which
  1. Updates a timestamp in an existing table
  2. Inserts a row into an audit table
I need the report to run the stored procedure, then based on the errorlevel, return a message.

How?
We use a database account with read-only privileges to list all the details. On the last report, the one to execute the stored procedure, we use an account specifically created to run the stored procedure. This requires using 2 data sources in SSRS.
  1. A user will specify the student reference in the parameters of the first report (the one with all the main details), as well as a job reference (for audit purposes) and click "View Report".
  2. The report will refresh with a link to a confirmation report which the user clicks and confirms that this is the student to update.
  3. The confirm button links to a 3rd report which will actually execute the stored procedure which updates the student record as well as an audit table.
The Problem
The last report will execute the stored procedure without any problems. I added a second dataset on this report to select the updated data that this stored procedure commits but unfortunately SSRS process both the Stored Procedure and the SELECT at the same time; this meant the report would say the process failed but when I check the logs, it successfully ran the stored procedure (updating both tables).

The Workaround
I want to avoid the workaround, because so far my workaround is a fourth report which will do the select to check that the update happened. Unfortunately this means that when the report was executed, it could only really display a message saying "executed stored procedure", "please click on the link to continue" and then the user would be taken to a report which says either "Stored Procedure was successful" or "No sorry you're going to have to go back to the beginning and try that again."... This isn't a solution that sounded good enough for our customers.

The Workaround we actually went with
Our Stored Procedure would check if the unique identifying number (in our case StudentID) matches a record in the database table and that the request number was alphanumeric. In addition, this would be checked at the database level, and returned in a dataset for SSRS to complete the check. Instead of outputting the error code to our end-users, we decided to store the error code in the audit table and that in the eventuality of an error happening, the end-user would contact us and we would look up this error code.

Instructions on setting up an Oracle Stored Procedure
I already wrote an article on this so please refer to SSRS Parameters in Oracle Stored Procedure.

Oracle: Grant another user permissions

  1.  /* on the table: ssrs_audit_table */ 
  2.  CREATE OR REPLACE PUBLIC SYNONYM ssrs_audit_table FOR base_table_owner.audit_table; 
  3.  GRANT SELECT, UPDATE, INSERT ON ssrs_audit_table TO ssrs_sp_user;  
  4.   
  5.  /* on the SP: ssrs_stored_procedure */ 
  6.  CREATE OR REPLACE PUBLIC SYNONYM ssrs_stored_procedure FOR base_table_owner.ssrs_stored_procedure; 
  7.  GRANT EXECUTE ON ssrs_stored_procedure TO ssrs_sp_user;  
  8.   
  9.  -- where ssrs_audit_table is a table that we want to use as an audit table 
  10.  -- where ssrs_stored_procedure is a stored procedure we made 
  11.  -- where ssrs_sp_user is the user to run the stored procedure in SSRS 
  12.  -- where base_table_owner is your base table owner 

Searches that got me nowhere
  • ssrs stored procedure successful or not

Comments   

mcf
# mcf Wed, 6th March 2013
I have not tried this, but i've seen on the internet that you could configure the datasource to run on a single transaction, and as long as the dataset running the sp is first, the select will be executed after it completes.
Like | Dislike | 0 Reply | Reply with quote | Quote
Add Comment

Name:

Email:

Website:

Message:


Latest Posts

  • Joes Word Cloud (JWC)

    • Sat 23-Aug-14
      Salut Joe, Thank you again for helping me. I had installed V2.2 for Joomla 2.5. Finally, as you ...
      Nathalie  
    • Wed 20-Aug-14
      Salut Nathalie! I could only access the under construction page of your website, so I'm not 100% sure.
      Webmaster  
    • Tue 19-Aug-14
      Hi Joe, Thank you for your prompt reply. Below, an "image" of the cloud on my website : "pour ante ...
      Nathalie  
    • Mon 18-Aug-14
      Hi Nathalie, Thanks for the message. The module does not see Virtuemart text but that sounds like ...
      Webmaster  
    • Mon 18-Aug-14
      Hi Joel, Fist of all, thank you for the module. What such a work ! I have a problem with Virtuemart module.
      Nathalie