有两张表A\B;
A表中有trans_no,id_code,trans_name,trans_initiator,start_date,re, type_1 ,type_2 ,type_3 ,type_4 ,type_5
B表中有type_1 ,type_2 ,type_3 ,type_4 ,type_5我想实现从B表中取出type_1 ,type_2 ,type_3 ,type_4 ,type_5中的数据,添加到A表中,但是同时在A表中还有从窗口输入trans_no,id_code,trans_name,trans_initiator,start_date,re列的数据.
下面是从B表取出数据到A表,但是,如果从窗口中输入的数据,要怎么改变下面方式可以进行添加 呢,或者不行?
insert into flow_trans_record (type_1 ,type_2 ,type_3 ,type_4 ,type_5) select distinct  type_1 ,type_2 ,type_3 ,type_4 ,type_5  from flow_control_maintain;

解决方案 »

  1.   

    可以换个思路嘛。
    在程序中把表b中的值先取出来然后和页面上的值一起传给sql语句
    按你的思路来的话,可以这样
    insert into flow_trans_record (trans_no,id_code,trans_name,trans_initiator,start_date,re,type_1 ,type_2 ,type_3 ,type_4 ,type_5) 
    (select distinct  #{trans_no},#{id_code},#{trans_name},#{trans_initiator},#{start_date},#{re},type_1 ,type_2 ,type_3 ,type_4 ,type_5  from flow_control_maintain) 
    #{trans_no}这种表示绑定的变量,也就是页面的值,具体怎么绑定我想你应该会吧。
      

  2.   

    是要这样子的存储过程?create or replace proc
    (
    v_trans_no A.trans_no%type,
    v_id_code A.id_ocde%type,
    v_trans_name A.trans_name%type,
    v_trans_initiator A.trans_initiator%type,
    v_start_date A.start_date%type,
    v_re A.re%type
    )
    AS
    BEGIN
    insert into flow_trans_record (type_1 ,type_2 ,type_3 ,type_4 ,type_5
    ,trans_no
    ,id_code
    ,trans_name
    ,trans_initiator 
    ,start_date
    ,re

    select distinct type_1 ,type_2 ,type_3 ,type_4 ,type_5
    ,v_trans_no
    ,v_id_code
    ,v_trans_name
    ,v_trans_initiator 
    ,v_start_date
    ,v_re
      from fow_control_maintain; 
    END;  
      

  3.   

    A.trans_no%type,
    这个是什么意思 呀 。
      

  4.   

    就是字段类型与A表中的trans_no字段一样
      

  5.   


    在我这是那个A应该用flow_trans_record 代替吧。 。