logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
dhd  
#1 Posted : Wednesday, June 26, 2019 2:56:42 PM(UTC)
dhd

Rank: Newbie

Groups: Registered
Joined: 6/17/2019(UTC)
Posts: 1
Brazil
Location: brasilia

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Hi Sealers,

I need to Execute a Stored Procedure to Populate Tables with parameters From a Common Restriction. Is there a way to do this?

I have two commom Restriction, CLIENT and REFERENCE_DATE


OR

Maybe, Creating two Report Input Values and execute the procedure in a TASK? How to execute this procedure from the Task using the Report Input values?

Edited by user Wednesday, June 26, 2019 2:58:22 PM(UTC)  | Reason: Not specified

epf  
#2 Posted : Wednesday, June 26, 2019 3:57:42 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Did you check the new documentation SQL Server Stored Procedures

The sample reports 21-SQL Server Stored Procedure with parameters should help you.
thanks 1 user thanked epf for this useful post.
dhd on 6/26/2019(UTC)
dhd  
#3 Posted : Wednesday, June 26, 2019 7:05:37 PM(UTC)
dhd

Rank: Newbie

Groups: Registered
Joined: 6/17/2019(UTC)
Posts: 1
Brazil
Location: brasilia

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Originally Posted by: epf Go to Quoted Post
Did you check the new documentation SQL Server Stored Procedures

The sample reports 21-SQL Server Stored Procedure with parameters should help you.


Thanks for Answering @epf!

Yes. I checked it.

I`m developing a workaround to achieve what we need.

I Created two Report Input Values named as CLIENT and REFERENCEDATE.

So, i created a task with the following code, executing the procedure with the Report Input Values as Parameters.

Code:

@using Seal.Model
@using Seal.Helpers
@using System.Data
@{
    //Query or update the database
    ReportTask task = Model;
    Report report = task.Report;
    var helper = new TaskHelper(task);

    ReportRestriction rstBanco = report.GetInputValueByName("CLIENT");
    ReportRestriction rstData = report.GetInputValueByName("REFERENCEDATE");
    
    string strData = String.Format("{0:yyyyMMdd}", rstData.FirstDateValue);

    helper.ExecuteNonQuery(
        "EXECUTE spu_relBI '"+rstBanco.EnumValues[0]+"', '"+ strData +"'", 
        false 
    );
}



Now i'm stuck in this scenario:

I have my SQL table populated dynamically from the procedure called in the Task. This is great!

How to use the Report Input Values in the Restrictions on our many models in this report??

epf  
#4 Posted : Thursday, June 27, 2019 6:39:12 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
The task will populate the SQL Table through the SP,
so you can have a model querying the Table (a SQL Model or a Metadata Model).
Be careful to use temp tables to avoid conflict if the reports is executed by 2 persons.

If you want to reuse the input value in a model restriction you should use the 'Pre Load Script' of the model:
Create a restriction in your model having the type of your input value.
Then edit the 'Pre Load Script' property of the model to assign the value of the InputValue to the restriction.
It will look like (for copying the enum value):

Code:
@using Seal.Model
@using System.Data
@{
    ReportModel model = Model;
    List<ReportRestriction> restrictions = model.Restrictions;

    ReportRestriction rstBanco = model.Report.GetInputValueByName("CLIENT");
    model.GetRestrictionByName("YourModelRestriction").EnumValues.Add(rstBanco.EnumValues[0]); 
}


However instead of creating input values, you should consider to use directly the restriction values in your Task.
You have direct access to your models restrictions, e.g. report.Models[0].GetRestrictionByName("YourModelRestriction")

In this case you do not need pre load script as the values are got from the restrictions.

Edited by user Thursday, June 27, 2019 10:04:27 AM(UTC)  | Reason: Not specified

thanks 1 user thanked epf for this useful post.
dhd on 7/1/2019(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.