Skip to main content
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

Uniface 9: U_WEHERE Help Needed

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

12 replies

Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

When I did something like this, I just made sure the current records had an id of 0 (zero).


Author: waderg (colpopski@outlook.com)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

well, you say that there is only one MM record per doc_no, so all rules about Normalisation (Peter CHEN) says the primary key is only this doc_no. But if you do not like changing the key, still the read u_where will work once you have collected all the MM records. On update, you create a new MM record to hold the new REV_NO, but to keep the "only one MM record" you have to delete the old record in the same transaction. Very error prone, isn't it?


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

FiresongKt said So the rev_no should not be part of the primary key of the MM table, it should instead be data. This makes it simple. Paint the MM table outside the other two, and set their read triggers to u_where rev_no.table = rev_no.mmtable When it comes time to copy them, use the release/e command on the OTHER two tables, not the MM table. This will disconnect the records from the database, you can then set the rev_no of the MM table to rev_no+1 and the rev_no of the other two tables to match.

REV_NO is part of the all three table primary keys.... I need to duplicate the record(s) and increase the rev_no at the same time to save the revised data and to keep history data in the same table with REV_NO as updating factor.


Author: se8mis (se8mis@ceb.lk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

So the rev_no should not be part of the primary key of the MM table, it should instead be data. This makes it simple. Paint the MM table outside the other two, and set their read triggers to u_where rev_no.table = rev_no.mmtable When it comes time to copy them, use the release/e command on the OTHER two tables, not the MM table. This will disconnect the records from the database, you can then set the rev_no of the MM table to rev_no+1 and the rev_no of the other two tables to match.


Author: Iain Sharp (i.sharp@pcisystems.co.uk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

Thank you for your quick reply.. I need more help until I am very new to uniface development. Actually what I need is this I have three tables GLBGTMM,GLBGTHM and GLBGTDM. all three tables are painted in the form. REV_NO is part of the PRIMARY KEYS is all three tables. Now in the user end user will need to update the records, to save those changes what I need to do is duplicate the current record by creating identical record and increase the rev no in all three tables MM table contains only one record per one doc number but other two will have multiple records, I need to change REV_NO of all those after user revised the values


Author: se8mis (se8mis@ceb.lk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

Thank you for your quick reply.. I need more help until I am very new to uniface development. Actually what I need is this I have three tables GLBGTMM,GLBGTHM and GLBGTDM. all three tables are painted in the form. REV_NO is part of the PRIMARY KEYS is all three tables. Now in the user end user will need to update the records, to save those changes what I need to do is duplicate the current record by creating identical record and increase the rev no in all three tables MM table contains only one record per one doc number but other two will have multiple records, I need to change REV_NO of all those after user revised the values


Author: se8mis (se8mis@ceb.lk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

FiresongKt said If you want to change out the read trigger (which I try to avoid) try read order by "DOC_NO,REV_NO:d" if($previous("DOC_NO") = DOC_NO) discard "$entname" (put $entname in great than less than, I can't get this daft software to show things in this form) endif This should cause it to throw away all the but the highest rev no of each document during the read phase.

Thank you for your quick reply.. I need more help until I am very new to uniface development. Actually what I need is this I have three tables GLBGTMM,GLBGTHM and GLBGTDM. all three tables are painted in the form. REV_NO is part of the PRIMARY KEYS is all three tables. Now in the user end user will need to update the records, to save those changes what I need to do is duplicate the current record by creating identical record and increase the rev no in all three tables MM table contains only one record per one doc number but other two will have multiple records, I need to change REV_NO of all those after user revised the values


Author: se8mis (se8mis@ceb.lk)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

I found the original listserver contribution from Dirk Willecke at: https://groups.google.com/d/msg/comp.soft-sys.app-builder.uniface/PYs34kQ7Dx8/UamEe-RqGa4J


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

from the days of uniface 5, there was a trick with the WHERE (not U_WHERE) string: not sure if the situation it is based still works with the database connectors of today under all circumstances because it depends that the WHERE string is placed at the very end of the generated SQL https://groups.google.com/d/msg/comp.soft-sys.app-builder.uniface/WtdpPYwCneA/OpbAbt5_uKIJ


Author: ulrich-merkel (ulrichmerkel@web.de)
Jan Cees Boogaard
Rocketeer
Nov 19, 2018 11:33 AM UTC

U_WEHERE Help Needed

Author: se8mis@ceb.lk (se8mis)

If I need to retrieve a set of Objects which having a maximum rev_no in a given table what will be the u_where condition Assume my table data as follows , I need to get only the * records TR_TBL DOC_NO REV_NO STATUS DEPT_ID AMT *Docno1 3 1 200 1 ---> Need to get Docno1 2 2 200 3 Docno1 1 1 200 1 *Docno2 2 1 200 10 ---> Need to get Docno2 1 2 200 1 *Docno3 2 1 200 2 ---> Need to get Docno3 1 1 200 1 I am using uniface 9.5.0.1 Version Regards Asiri

If you want to change out the read trigger (which I try to avoid) try read order by "DOC_NO,REV_NO:d" if($previous("DOC_NO") = DOC_NO) discard "$entname" (put $entname in great than less than, I can't get this daft software to show things in this form) endif This should cause it to throw away all the but the highest rev no of each document during the read phase.


Author: Iain Sharp (i.sharp@pcisystems.co.uk)