I'm a beginner with application builders and I want to achieve the following: I'm currently retrieving data from a database using SQL with a specific time period. However, instead of directly modifying the SQL code to change the period, I want to be able to change it via a GUI. I'm currently executing this with JSL, and I want to replace the [HERE]
part of the SQL query.
Example JSL:
// Get a handle to the data table
dt = Current Data Table();
unique = Function({a}, // input: List, output: List
{aa=Associative Array(),nr=NItems(a),i,aKeys,nUnique,aUnique={}},
For( i=1, i<=nr, i++, aa << insert( a[i] ) );
aKeys = aa << GetKeys;
nUnique = NItems( aKeys );
For( i = 1, i <= nUnique, i++, InsertInto(aUnique,aKeys[i]) );
aUnique
);
dofun = Function({},{months,varName,dType},
months = SampleRateInput << Get;
varName = VarList << GetSelected;
dType = Column(dt,varName[1]) << GetDataType( "English");
If(dType!="Character",
Dialog(Title("Alert"),"Data Type of Variable should be Character. ");
Throw()
);
dt << ClearSelect;
dt << SelectRows( selIdx );
);
OKButtonPress=Function({this},
// This function is called when the OK button is pressed
(thisModuleInstance << Get Box) << Close Window;
dofun;
);
CancelButtonPress=Function({this},
// This function is called when the Cancel button is pressed
(thisModuleInstance << Get Box) << Close Window;
);
New SQL Query(
Version( 130 ),
Connection( ),
QueryName( ),
Select( ),
From(
Table( ),
),
Where(
Custom(
"t1.msr_dt >= DATEADD(month, -[HERE], CURRENT_DATE)",
UI( Custom( Base( "Continuous" ) ) )
)
)
) << Run Foreground( UpdateTable( Current Data Table() ) );