TOPIC: BrowseControl with tables joined and delete
#1126
BrowseControl with tables joined and delete 2 Years, 6 Months ago
Hi

another problem

i have only a Browse(without Access)
the query is two tables JOINed
"(pre_nat_piatti join pre_nat_piatqr) sort pr1pos, pr1des"

work normally but when i delete a record in the Browse window
the delete is not done and is displayed this error in the debug window:
query can't erase
query delete (pre_nat_piatti join pre_nat_piatqr) where pr4id = #20080212.142344692

pr4id is the id of pre_nat_piatqr
pr1id is the id of pre_nat_piatti
i want to delete the pre_nat_piatti record, but i see that with Browse and JOIN it is not possible. The exact query to delete is
delete pre_nat_piatti where pr1id = #20080119.151251329
In this Browse i need the fields of pre_nat_piatti and from pre_nat_piatqr i have to display in browse only the field pr4qri


thanks in advance

Claudio
 
 
#1128
Re:BrowseControl with tables joined and delete 2 Years, 6 Months ago
Joins are only update-able if they are one to one i.e. the join field is a key on both tables.

If you just want to display fields from other tables you can use rules that look up the other information.

To handle delete you could re-define delete to work the way you want. (I think you asked about this before.)
 
 
andrew
 
#1133
Re:BrowseControl with tables joined and delete 2 Years, 6 Months ago
i used extend and rule to solve the problem

1)
to pre_nat_piatti i added a derived field Pr1qri

2)
Rule_pr1qri
function()
{
try r= Query1(.tabpiatqr$' where pr1id = '$Display(.pr1id))
catch r= false //when tabpiatqr is not defined to can use QueryView
if (r is false) return 0
return r.pr4qri
}

3)
in cols i added pr1qri to display the field in the browse
the new browse query:
.bwpiat.SetQuery(.tab_piatti$" extend tabpiatqr = "$Display(.tab_piatqr)$" sort pr1pos, pr1des", columns:cols)
i used 'extend' because i do not know the content of .tab_piatqr

seem that work fine and now i can delete the record :)
and i can use pr1qri too for printing the records

may be that is interesting add to Rule in suneidoc something like this:
<The only way to pass information to a rule is to put the information in the record.
For example, you could add a query temporary field: table extend tempinfo = "othertable">

thanks

Post edited by: claudio08, at: 2008/02/13 07:30

Post edited by: claudio08, at: 2008/02/13 07:38