My DataView is based on this query:
SELECT
`BoardReports`.`BoardReportsKey` AS `BoardReportsKey`,
`BoardReports`.`BoardPositionKey` AS `BoardPositionKey`,
`BoardReports`.`ReportKey` AS `ReportKey`,
`BoardPositions`.`PositionName` AS `PositionName`,
`Reports`.`ReportTitle` AS `ReportTitle`
FROM
`BoardReports`
INNER JOIN `BoardPositions` ON (
`BoardReports`.`BoardPositionKey` = `BoardPositions`.`BoardPositionsKey`
)
INNER JOIN `Reports` ON (
`BoardReports`.`ReportKey` = `Reports`.`ReportsKey`
)
WHERE `BoardPositions`.`BoardPositionsKey` = '0b1dba54-39e9-4e48-9447-768f2af111e4'
-- WHERE `BoardPositionsKey` = ?
It works fine so far. when run as above in the query designer it returns the proper record. to run in production, I remove the comment mark on the last line and insert comment mark on the other WHERE, then save the query. So far so good.
What I really want is to show ALL reports in the DataView, not just the ones that are in the join table (BoardReports).
I tried the following query:
SELECT
br.`BoardReportsKey` AS `BoardReportsKey`,
br.`BoardPositionKey` AS `BoardPositionKey`,
r.`ReportsKey` AS `ReportsKey`,
r.`ReportTitle` AS `ReportTitle`
FROM `Reports` AS r
LEFT JOIN `BoardReports` AS br
ON r.`ReportsKey` = br.`ReportKey`
-- AND br.`BoardPositionKey` = ?
AND br.`BoardPositionKey` = '0b1dba54-39e9-4e48-9447-768f2af111e4'
ORDER BY `ReportTitle`;
This works perfectly in design-time, and I can run the query. it properly returns all reports, and the one that is in the join table for this BoardPosition shows pertinent values from the join table.
Unfortunately, when I reverse the comments on the AND clauses and save the query, at run-time I get an error “Can’t parse query”
Perhaps the query parser can’t handle parameters in a join? I’ve verified that the parameter has the proper value at run-time.
I want the dataview to show all reports, with the ones that are selected (in the join table) indicated by other values being visible on those lines. I will take care of that part, but I need to get the query/dataview working.
Can you tell me if what I want is even possible? If I can’t show ALL reports in the dataview, I can work around that by having an “Add Report” action button which opens up another form to add a record to the join table. But I’d rather not do that if not needed. I already have code to swap the record in and out of the join table when the dataview item is clicked, but I need the dataview to be able to show the items.
I used ChatGPT to try and solve this, but it doesn’t have specialized knowledge of how Five works, and can’t solve the issue. Can you folks help me?
Thanks…