Forum Discussion
PB
2 years agoNew Contributor II
Execute sql on data table
Can I execute an sql statement against a data table created in a business rule? I created a table to use in a data set business rule, which returns data to the data adapter.
e.g. if I created d...
- 2 years ago
The datatable exists within the data set business rule, so yes you can run a query against it, but within its limit of existence, as for any other variable, i.e. you cannot refer to it from other business rules or outside the function or loop where it is defined. However, even within its limit of existence, I believe you cannot refer to it with the "select * from dt1" string. You need to use the appropriate function of the BRApi.Database (I don't remember which one at the moment), and pass the table and where/order by etc. as parameters.
Krishna
2 years agoValued Contributor
AndreaF - Yes Data table are in memory and you can manipulate by copying to another DTL or you can use the existing DTL as well. See below an example
WFICTable1 = WFICTable.Copy()
Dim distinctValues = WFICTable1.AsEnumerable() _
.Where(Function(row) row.Field(Of String)("Account") <> "Difference") _
.GroupBy(Function(row) New With {
Key.Column1 = row.Field(Of String)("Entity"),
Key.Column2 = row.Field(Of String)("IC")
}) _
.Select(Function(Group) New With {
.Column1 = Group.Key.Column1,
.Column2 = Group.Key.Column2,
.OtherColumn1 = Group.First().Field(Of String)("Account"),
.OtherColumn2 = Group.First().Field(Of String)("PartnerCurr"),
.OtherColumn3 = Group.First().Field(Of Decimal)("RptCurrAmount"),
.OtherColumn4 = Group.First().Field(Of Decimal)("PrimaryCurrAmount"),
.OtherColumn5 = Group.First().Field(Of Decimal)("PartnerCurrAmount")
})
PB
2 years agoNew Contributor II
Thanks Krishna - I'll check it out - looks like your doing something on IC mismatch reporting - that's what I'm working on with this issue too.
Related Content
- 3 years ago