补充下,页面显示的记录是按照一定查询条件从表中检索出的,但是a、b、c三表的检索策略基本相同

解决方案 »

  1.   

    A表F1,F2,F3
    B表F1,F2,F3
    C表F1,F2,F3CREATE VIEW abc
    AS
    (SELECT F1,F2,F3 from A) UNION (SELECT F1,F2,F3 from B) UNION (SELECT F1,F2,F3 from C)然后操作视图就和操作普通表一样
      

  2.   

    用视图做完全没问题,视图里的数据可以来自不同的表的。在视图里给他们统一成一个别名就OK。
    create or replace view V_$Worker as
      select rnum,oper,opername,opdate from(
             select rnum,rfillope as oper,rfillopename as opername,rfilldate as opdate
             from relic where (rfillope is not null or rfillope <> '') and (rfilldate is noy null)
             union all 
             select rnum,wfillope as oper,wfillopename as opername,wfilldate as opdate
             from wound where (wfillope is not null or wfillope <> '') and (wfilldate is noy null)
             union all 
             select rnum,cfillope as oper,cfillopename as opername,cfilldate as opdate
             from catalog where (cfillope is not null or cfillope <> '') and (cfilldate is noy null)
             union all 
             select rnum,vfillope as oper,vfillopename as opername,vfilldate as opdate
             from verify where (vfillope is not null or vfillope <> '') and (vfilldate is noy null)
             union all 
             select rnum,jfillope as oper,jfillopename as opername,jfilldate as opdate
             from judge where (jfillope is not null or jfillope <> '') and (jfilldate is noy null)
             union all  
             select rnum,rauditope as oper,rauditopename as opername,rauditdate as opdate
             from relic where (rauditope is not null or rauditope <> '') and (rauditdate is noy null)
             union all  
              select rnum,wauditope as oper,wauditopename as opername,wauditdate as opdate
             from wound where (wauditope is not null or wauditope <> '') and (wauditdate is noy null)
             union all  
              select rnum,cauditope as oper,cauditopename as opername,cauditdate as opdate
             from catalog where (cauditope is not null or cauditope <> '') and (cauditdate is noy null)
             union all  
              select rnum,vauditope as oper,vauditopename as opername,vauditdate as opdate
             from verify where (vauditope is not null or vauditope <> '') and (vauditdate is noy null)
             union all  
              select rnum,jauditope as oper,jauditopename as opername,jauditdate as opdate
             from judge where (jauditope is not null or jauditope <> '') and (jauditdate is noy null)
             union all  
    )
    你参考下这个视图创建语句看有帮助没。
      

  3.   

    小弟对视图不是十分理解。。
    像我这样的情况视图是事先创建好还是在程序当中创建呢。。?视图当中的数据是在什么时候导入的呢?再拿sureyor举的那个例子说下,
    A表F1,F2,F3
    B表F1,F2,F3,F4
    C表F1,F2,
    从各个基表中取出的列可能会略有不同,如果是这种情况呢?能够取各个表列的最大集合么。。?没有的列就默认为空?
      

  4.   

    直接建个视图就全解决了呀!
    create or replace view view_A_B_C
    as (
    select a.字段, ... from A a where ...
    union all
    select b.字段, ... from B b where ...
    union all
    select c.字段, ... from C c where ...
    )
      

  5.   

    还有另外一个问题,因为从ABC三表当中检索出的字段包括主键oid,而在应用当中是要给oid这项加上基于表名的前缀的,例如A01,B02等等。放在视图当中我无法判断是属于哪张表的记录。。也就没有办法加前缀
    貌似这个问题从数据库着手是无解了。。
      

  6.   

    再拿sureyor举的那个例子说下, 
    A表F1,F2,F3 
    B表F1,F2,F3,F4 
    C表F1,F2, 
    从各个基表中取出的列可能会略有不同,如果是这种情况呢?能够取各个表列的最大集合么。。?没有的列就默认为空?
    --------------------------
    for examle 
    select a.f1, a.f2, a.f3, "a.dummy" --这里用空字符串""也可以,或者用其他提示也可以,自己决定,总之,把列补齐就行
      from a
     where xxx
    union all
    select b.f1, b.f2, b.f3, b.f4
      from b
     where xxx
    union all
    select c.f1, c.f2, "c.dummy1", "c.dummy2"
      from c
     where xxx
      

  7.   

    CREATE   VIEW   abc
    AS
    (SELECT   F1,F2,F3,'' F4   from   A)   UNION   
    (SELECT   F1,F2,F3,F4   from   B)   UNION   
    (SELECT   F1,F2,'' F3,'' F4   from   C) 这样abc视图就有四个字段F1,F2,F3,F4,当然上面的默认值''可以根据你实际的需要来自行设置
      

  8.   

    方法1: 用视图用SQL语句Union三张表
    方法2: 取出来放到一个List里,要求每个对象应该有相同的页面列表需要的get方法(如果记录不是太多)
      

  9.   

    设置一个抽象业务类x
    有三个子类a,b,c
    看子类的私有属性多不多   不多的话就只设一张x表  subclass
                             多的话设4张表          joined-subclass
    这样取起来就很容易
      

  10.   

    遗留系统的话  如果用sql处理起来很复杂  我觉得尽量还使用程序来处理
    毕竟太依赖数据库   以后维护 移植的风险要大很多
      

  11.   

    关于arthew所说的list方法也想过,但是排序和分页就麻烦很了,需要按照多个字段排序,需要写n个compareto不说,我总不能把所有记录全部取出来放在list里面。。另回gougou8180,现在的继承结构已经定了,我不可能再去更改继承树了。。
      

  12.   

    http://www.finereport.com
    看看.也许你能够得到帮助的!
      

  13.   

    建视图的时候你想加什么前缀就加什么前缀
    而且查询视图跟查询表的结果完全一样
    只要你不做insert update delete 操作即可