I have the following query
select x from ProjTable
join GeneralAccEntry
on (Projtable.ProjId= substr(GeneralAccEntry.fieldy), 25,7)
I created a form with ProjTable
as main datasource. Now I want to add a calculated display field which shows the sum of fieldY
from the related GeneralAccEntry
table. I'm having difficulties retrieving the sum per projId
because the method doesn't take projId
as a parameter.
What's the correct way to create this display method?
Just try with "WHERE" instead of "ON".
select x
from ProjTable
join GeneralAccEntry
WHERE Projtable.ProjId = substr(GeneralAccEntry.fieldy, 25,7)
Be careful with comparing using a function, it may give you an error. In case it does try to assign the result of the substr to a str variable with a defined length (like str 20 varName).
Not sure if I understand your question correctly. But would the following resolve your problem:
Add method to your table ProjTable:
public display real sumOfGeneralAccEntry()
{
GeneralAccEntry generalAccEntry;
str filter = '*' + this.ProjId + '*';
select sum(fieldY)
from generalAccEntry
where generalAccEntry.fieldY like filter;
return generalAccEntry.fieldY;
}
Add the display to a field group
Add the fieldgroup into your form
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.