How to display the different values for all template repeaters on clicking on one Button

Hi,
we have 5 machines, for all machines we need to show total good parts for different timings on clicking on button. values are coming from PLC and storing it in DB for 15 mins.
here is my template, I binded this for named query for 30 mins.

Here is my main View,
I can use multistate button or single button for different timings. by clicking on button, value should change in all machine fields(TextField)

please guide

Can you not set a parameter in your named query, for the 'inputMin' and machine name. And just put the minutes parameter, etc. in there?

here is my SQL query for 60min, so I can change it for 30,80 and so on.
On clicking on 30 mins Button it should change for all machines.

DECLARE @currentdttm datetime 
DECLARE @inputMin int
SET @inputMin = 60
SET @currentdttm = SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')

 


SELECT DateTime,TOTALGOODPARTS 
FROM ROUGHER_PLC_DB  
WHERE DateTime <  @currentdttm
AND DateTime > dateadd(minute, -@inputMin, @currentdttm)

 

 

declare @MinHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Min int,
hour_min int
)
declare @MaxHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Max int,
hour_max int
)
BEGIN

 

    BEGIN
    INSERT INTO @MinHours
        select  TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB 
        where 1=1
        AND DateTime <  @currentdttm
        AND DateTime > dateadd(minute, -@inputMin, @currentdttm) 
        order by DateTime asc
    END

 

    BEGIN
    INSERT INTO @MaxHours
        select  TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB 
        where 1=1
        AND DateTime <  @currentdttm
        AND DateTime > dateadd(minute, -@inputMin, @currentdttm)
        order by DateTime desc
    END
END
--Select * from @MinHours;
-- Select * from @MaxHours;
select MAX.Date_Time as MAX_TIME,MIN.Date_Time as MIN_TIME,MAX.TOTALGOODPARTS_Max - MIN.TOTALGOODPARTS_Min as GOOD_PARTS
from @MaxHours MAX 
INNER JOIN @MinHours MIN
ON MAX.S_NO = MIN.S_NO

If the only thing you change is the variables at the top you could set a paramter in the named query and put

@inputMin = :newValue1

etc.

for example

In the binding on your repeated view, put your parameter into this value

ok I will try. thanks

please can you check this , is it correct, Sorry I am not getting how it will work on clicking on button,
Please guide

Ewww! Don't do that. That is not JDBC compliant, and is only likely to work on SQL Server. Just put the colon-delimited parameters where appropriate.

1 Like

sorry, I am not getting.
Can you please guide how I can bind it and on Button.
you can find my screen in attachment.
Template_View_values.zip (52.7 KB)