Model analyzer and related checks

Author: claudio.palladini@cortislentini.it (Claudio)

Hello everyone, I'm just getting started with Uniface (in my case 9.3) and, playing with Model Analyzer, I found that it does not report problems in case I have defined a foreign key between two fields that have a different type. Classical example: relationship between a char field with and a number field. In a logical relationship I could be agree with M.A., while leaving to the programmer the entire management of the relationship, though could give me at least a hint. In a physical relationship where I want to use a referential integrity constraint, I would expect that Uniface print automatically (and directly send to my boss) the letter of resignation. Seriously, in my Uniface version the M.A. don't make this kind of check, there is an option in environment to ensure that the M.A. to perform it? Thanks all Claudio

15 Comments

  1. Hi, The Uniface product has a long history. In the distant past Uniface could only enforce a relationships by having the entities painted on a Form (Frames with Frames). This type of enforcement still exists and it still is the default behavior. In many cases Uniface can handle a difference in data types through its automatic type conversion. That is why it does not give you an ERROR. I agree with you that a relation over different data types is bad programming, so it would have been nice if a WARNING had been issued. Later support for generating referential integrity in your database was added (optional). Some databases support relationships over different data types and others do not. It would have been good if warning had been added to Analyze Model at this point. There unfortunately is no option that you can set on Analyze Model. I took the liberty of adding a wish to the wish list on this site for adding a warning: http://unifaceinfo.com/warning-for-mismatched-data-types-in-relationship/


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  2. Hi Theo, thanks for your reply and for putting my idea in the Uniface's wishlist. In a Model Analyzer tool, I thought this kind of check is at the base, but is my personal opinion (sadness and sorrow...).Frown So, what kind of controls the Model Analyzer do? Bye Claudio


    Author: Claudio (claudio.palladini@cortislentini.it)
  3. Claudio said Hi Theo, thanks for your reply and for putting my idea in the Uniface's wishlist. In a Model Analyzer tool, I thought this kind of check is at the base, but is my personal opinion (sadness and sorrow...).Frown So, what kind of controls the Model Analyzer do? Bye Claudio  

    Hi Claudio UnifAce will check, *if a field in the component  is longer as it could be stored on DBMS *if there is a primary key *if relations ships do have enough fields defined on n-side If you need a check as you mentioned, you can do this by a little bit of programming. Loop over all relationsships (UCRELSH)   Get the keyfields of the one-Side (UCKEY)   Get the foreign fields of the n-Side (UCRELSH)   Compare field-defintions (UCFIELD) Ingo


    Author: istiller (i2stiller@gmx.de)
  4. Ingo: +1


    Author: Daniel_Kurz (kurzster@gmail.com)
  5. Daniel_Kurz said Ingo: +1  

    Uniface: -1 Wink


    Author: Claudio (claudio.palladini@cortislentini.it)
  6. istiller said
    Claudio said Hi Theo, thanks for your reply and for putting my idea in the Uniface's wishlist. In a Model Analyzer tool, I thought this kind of check is at the base, but is my personal opinion (sadness and sorrow...).Frown So, what kind of controls the Model Analyzer do? Bye Claudio  
    Hi Claudio UnifAce will check, *if a field in the component  is longer as it could be stored on DBMS *if there is a primary key *if relations ships do have enough fields defined on n-side If you need a check as you mentioned, you can do this by a little bit of programming. Loop over all relationsships (UCRELSH)   Get the keyfields of the one-Side (UCKEY)   Get the foreign fields of the n-Side (UCRELSH)   Compare field-defintions (UCFIELD) Ingo  

    Thanks Ingo. I would share my Oracle Script, but there are many things imprecise. So take it as sample to improve at your requirement. (sorry for formatting, but in this board I cannot find the right tool to improve it).   HTH

    /* Loop over all relationsships (UCRELSH) Get the keyfields of the one-Side (UCKEY) Get the foreign fields of the n-Side (UCRELSH) Compare field-defintions (UCFIELD) */ declare v varchar2(1000); fldmaster varchar2(1000); flddetail varchar2(1000); mstdlftyp varchar2(1000); detdlftyp varchar2(1000);

    function remmetatags(param in out varchar2) return varchar2 is begin param := replace(param, '<UVALKEY>T</UVALKEY>', ''); param := replace(param, '<U_ARITYMAX>0</U_ARITYMAX>', ''); param := replace(param, '<unimeta>', ''); param := replace(param, '</unimeta>', ''); param := replace(param, '<U_FLABS>', ''); param := replace(param, '</U_FLABS>', ''); param := regexp_replace(param, '(.+U_DOC>).+(U_DOC>)', '', 1, 0, 'inm'); param := replace(param, chr(13), ''); return param; end;

    procedure comparefld(mtab varchar2, mfld varchar2, dtab varchar2, dfld varchar2) is mtyp varchar2(100); mintf varchar2(100); msyn varchar2(100); mlay varchar2(100);

    dtyp varchar2(100); dintf varchar2(100); dsyn varchar2(100); dlay varchar2(100); begin begin select t.u_dtyp, t.u_intf, t.u_syn, t.u_lay into mtyp, mintf, msyn, mlay from ucfield t where /*t.u_indb = 'Y' and*/ t.u_tlab = mtab and t.u_flab = mfld; select t.u_dtyp, t.u_intf, t.u_syn, t.u_lay into dtyp, dintf, dsyn, dlay from ucfield t where /*t.u_indb = 'Y' and*/ t.u_tlab = dtab and t.u_flab = dfld; if (mtyp <> dtyp) then dbms_output.put_line('Type differs: '||mtab||'.'||mfld ||' and '||dtab||'.'||dfld); end if; if (mintf <> dintf) then dbms_output.put_line('Intf differs: '||mtab||'.'||mfld ||' and '||dtab||'.'||dfld); end if; if (msyn <> dsyn) then dbms_output.put_line('Syn differs: '||mtab||'.'||mfld ||' and '||dtab||'.'||dfld); end if; if (mlay <> dlay) then dbms_output.put_line('Lay differs: '||mtab||'.'||mfld ||' and '||dtab||'.'||dfld); end if; /*if nvl(mtyp, '-') = nvl(dtyp, '-') and (nvl(mintf, '-')=nvl(dintf, '-')) and (nvl(msyn, '-')=nvl(dsyn, '-')) and (nvl(mlay, '-')=nvl(dlay, '-')) then dbms_output.put_line('That''s OK man!'); end if; */ exception when others then dbms_output.put_line(sqlerrm); end; end;

    begin for rel in (select * from UCRELSH order by u_glab ) loop dbms_output.put_line('TABELLAM: '||rel.u_glab); dbms_output.put_line('TABELLAD: '||rel.u_rglab); flddetail := remmetatags(REL.u_doc); dbms_output.put_line('FDETAIL: '||flddetail);

    for keyf in (select * from UCKEY where rel.u_glab = UCKEY.u_tlab and UCKEY.u_ktyp = 'P' order by UCKEY.u_kseq) loop fldmaster := remmetatags(keyf.u_doc); dbms_output.put_line('FMASTER: '||fldmaster); for flds in (select * from (select regexp_substr(fldmaster, '[^,]+', 1, level) mres, level mlev from dual connect by level <= length(regexp_replace(fldmaster, '[^,]+')) + 1 ) a, (select regexp_substr(flddetail, '[^,]+', 1, level) dres, level dlev from dual connect by level <= length(regexp_replace(flddetail, '[^,]+')) + 1 ) b where a.mlev=b.dlev ) loop comparefld(rel.u_glab, flds.mres, rel.u_rglab, flds.dres); end loop; end loop; end loop; end;


    Author: Claudio (claudio.palladini@cortislentini.it)
  7. Just a question: why an Oracle stored procedure instead of a small Uniface form/service on Meta Dictionary?Wink Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  8. gianni said Just a question: why an Oracle stored procedure instead of a small Uniface form/service on Meta Dictionary?Wink Gianni  

    I'm waiting for practical lessons about Uniface. At now, I'm only an help reader! :D


    Author: Claudio (claudio.palladini@cortislentini.it)
  9. Claudio said
    gianni said Just a question: why an Oracle stored procedure instead of a small Uniface form/service on Meta Dictionary?Wink Gianni  
    I'm waiting for practical lessons about Uniface. At now, I'm only an help reader! :D  

    Well, I am here to help if needed... (Se servisse aiuto potremmo vederci, se necessario...) My email is: gianni.sandigliano@unifacesolutions.com Ciao, Gianni P.S. I am putting together a small working example using Uniface meta dictionary to support your need...I'll be back soon...


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  10. I have a draft working example implemented with Uniface over Meta Dictionary; it could be used as an interactive form and also as a service (hidden form) calling a specific operation. ...but I've never attached an export to a post... CoolCoolCool ...if anyone interested send me an email to gianni.sandigliano@unifacesolutions.com. Ciao, Gianni P.S. Uniface scored and tied the game! 1-1


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  11. Hi Gianni, Attachments to a forum post are not possible. You could upload your sample to the 'Community Samples' section and then refer in the comments to this thread (via URL). Vice Versa you could put a URL in this thread to the Community Sample. Best regards, Arjen


    Author: Arjen van Vliet (arjen.van.vliet@uniface.com)
  12. I've added to Community Samples a small form (GSX_RELACHECK) on Aug, 30 2016 to be used to check relationships coherence into Uniface Repository. Pre-requisite to compile this form is to import Meta Dictionary (<InstallDir>\uniface\misc\umeta.xml). Hope it helps Claudio as well as all Unifacers needing such extended functionality. Ciao, Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  13. gianni said I've added to Community Samples a small form (GSX_RELACHECK) on Aug, 30 2016 to be used to check relationships coherence into Uniface Repository. Pre-requisite to compile this form is to import Meta Dictionary (\uniface\misc\umeta.xml). Hope it helps Claudio as well as all Unifacers needing such extended functionality. Ciao, Gianni  

    Thanks Gianni, I will be download the example as just figured out how can I install it without the risk of making damage to the repoLaugh. Unfortunately I lack the immediacy that I had with development environments I've worked with before, Uniface is a bit tricky and not so immediate as I would have hoped. Claudio


    Author: Claudio (claudio.palladini@cortislentini.it)
  14. Hi Claudio, I focus only now your company is still on Uniface 9.3 (Could it be because of WindowsXP legacy support?) so it is better you coordinate your efforts with one of your system admins... Anyhow it is a simple task because it is a "non destructive" one... 1) From development environment, browsing application models, verify if models DICT,PRINTER,SYSENV are available; if they are NOT available import meta dictionary into your current repository starting your development environment again and typing "/ins meta" in the command window. 2) Restart development environment got to Utilities->Import, browse for GSX_RELACHECK.exp, select it and push Import button. Compile and test the form. While testing simply push the "Start checks" button to have your relationship coherence checked. Output by default will be sent to message frame; Message Frame is automatically opened when checks are completed. You could also open the .exp file with a text editor to browse the code because it is in xml format... Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  15. gianni said Hi Claudio, I focus only now your company is still on Uniface 9.3 (Could it be because of WindowsXP legacy support?) so it is better you coordinate your efforts with one of your system admins... Anyhow it is a simple task because it is a "non destructive" one... 1) From development environment, browsing application models, verify if models DICT,PRINTER,SYSENV are available; if they are NOT available import meta dictionary into your current repository starting your development environment again and typing "/ins meta" in the command window. 2) Restart development environment got to Utilities->Import, browse for GSX_RELACHECK.exp, select it and push Import button. Compile and test the form. While testing simply push the "Start checks" button to have your relationship coherence checked. Output by default will be sent to message frame; Message Frame is automatically opened when checks are completed. You could also open the .exp file with a text editor to browse the code because it is in xml format... Gianni  

    Thanks again, Gianni.   Ciao Claudio PS: who must know, already know!Wink


    Author: Claudio (claudio.palladini@cortislentini.it)