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

forentity which includes discard or remocc do not work, as stated in the helpfile. Instead of the view you can use the following strategy using all the new features of read: At first, we read all records (MAXHITS=ALL), use a putlistitems command to get a list of DOC_NO then we do a sort/list with unique option we clear/e our entity and now collect the records DOC_NO by DOC_NO: We use forlist and for each DOC_NO, we start a retrieve/a with the order_by rev_no:descending in the read trigger, we use MAXHITS=1 to get only the highest version.


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

I don't think you can do this with u_where. You could retrieve the data, sort by doc_no then rev_no:descending and loop through discarding the ones which are the same doc_no as the previous doc_no. sort/e "TR_TBL", "DOC_NO,REV_NO:d" forentity "TR_TBL" if(v_doc_no = doc_no) discard "TR_TBL" else v_doc_no = doc_no endif endfor Alternatively, and depending on your database, you could make an updateable view on tr_tbl :- select * from tr_tbl where rev_no = (select max(rev_no) from tr_tbl t2 where t2.doc_no = tr_tbl.doc_no) And use this as the table within Uniface. Uniface does not do set based queries itself, and therefore cannot reference the max rev no, unless you had another table/view storing doc_no,max(rev_no)


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