可以的.检查程序中在那出错
SQL> select * from aa;ID FID
-- ---
1  0
2  1
3  1
4  2
5  3
6  4
6  57 rows selectedSQL> select * from bb;A  B
-- --
1  0
2  1
3  1
4  2
5  3
6  4
6  57 rows selectedSQL> select id,fid from aa
  2  union all
  3  select a,null from bb;ID FID
-- ---
1  0
2  1
3  1
4  2
5  3
6  4
6  5
1  
2  
3  
4  
5  
6  
6  14 rows selected

解决方案 »

  1.   

    你的T3035.EXAM_DATE g 是date类型,所以在后面的select中,应该
    to_date(null,'yyyy-mm-dd') g
      

  2.   

    date型在附值时直接附null不要类型转换的
      

  3.   

    select abc.a,abc.b,abc.c,abc.d,abc.h ,abc.f
      from (select t3005.p_code a,
                   t3017.c_name b,
                   t3020.rank_name c,
                   t3005.fly_hours d,
                   t3020.rank_no e,
                   t3005.flight_date f,
                   T3035.EXAM_DATE g ,
                   decode(T3035.RESULT, '1', 'ÒÑÍê³É', '2', 'δͨ¹ý', '--') h 
              from t3005, t3017, t3035, t3020
             where t3005.crew_link_line=' & crew_link & '
               and t3005.p_code=t3017.p_code
               and t3005.p_code=t3035.p_code
               and t3005.flight_date=t3035.EXAM_DATE
               and t3005.rank_no=t3020.rank_no
               and To_Char(t3005.flight_date,'YYYY-MM-DD')=' & sDay & '
            union all 
            select t3016.p_code a,
                   t3017.c_name b,
                   t3020.rank_name c,
                   t3016.fly_hours d,
                   t3020.rank_no e,
                   t3016.flight_date f,
                   null g ,
                   null h 
              from t3016, t3017, t3020 
             where t3016.stew_link_line=' & stew_link & '
               and t3017.p_code=t3016.p_code
               and t3020.rank_no=t3016.rank_no
               and To_Char(t3016.flight_date,'YYYY-MM-DD')=' & sDay & ')  abc
    order by abc.e;看不出有什么错啊,在sqlplus中执行一下看看问题出在哪一行
      

  4.   

    null 类型与date类型不一致。
    将null 改为to_date(null) 即可!
      

  5.   

    select col1,...col7 from  tab1_name  union select col1,...col5 from tab2_name 即可,这是一个联合查询,即可以实现两个查询的列匹配。
      

  6.   

    sql=sql+"        t3016.flight_date f, null  g , null  h "换成:sql=sql+"        t3016.flight_date f, to_date(null)  g , null  h "