View based join tables

Help
2009-07-03
2013-04-16
  • Carlos Ramos
    Carlos Ramos
    2009-07-03

    Hi, how i can  create a view based in join two tables?. For example, my SQL is:

    SELECT A.NAME,A.ID,B.TYPE
    FROM CLIENTS A, TYPES B
    WHERE A.ID=B.ID AND B.TYPE=2

    Thanks.

     
    • Hi, in view definition use method setRelations for example:

      Package: test
      Table1: A
      Table2: B

      viewDef.setFrom("aliasA:table@test.A;aliasB:table@test.B");
      viewDef.setRelations("-:aliasA.ID=aliasB.ID");
      viewDef.setColumns("@All");

      the syntax of method setFrom is: <Alias1>:<Type1>@<PackageName>.<Name1>; ... ;<AliasN>:<TypeN>@<PackageName>.<NameN>

      <Alias> is logic name <Type> is table or view  <PackageName>.<Name> is full name of table or view

      the syntax of method setRelations is: <TypeRel1>:<AliasRel1_1>.<ColRel1_1>=<AliasRel1_2>.<ColRel1_2>&& ... ; ....
                                             
      <TypeRel> is relation type:
          >   left join
          <   right join
          -   inner join
         
      the syntax of method setColumns is: <AliasCol1>:<Expression1> ; ... ; <AliasColN>:<ExpressionN>

      Danilo

       
      • Carlos Ramos
        Carlos Ramos
        2009-07-03

        Ok, thanks for your help, anyway I continue seeing the application, it seems to me to be interesting enough.

         
    • sorry i have forget B.TYPE=2:

      viewDef.setFrom("A:table@test.CLIENTS;B:table@test.TYPES");
      viewDef.setRelations("-:A.ID=B.ID");
      viewDef.setColumns("NAME:A.NAME;TYPE:B.TYPE");
      viewDef.setCondition("B.TYPE=2");

      Danilo