具体思路是根据传进来的字符串custNO 去查询第一张表 把查到的记录所有行拼接成字符串 如果第一张表中没有数据 就去查第二张表  如果都没有数据 就把输出参数给一个固定的字符串
以下是我自己写的一个错误的 希望高手根据自己的思路写一个完整的  一定要完整的额 所有的字段全部是字符串类型的
 
create or replace procedure pre_allRate(p_cust_no   in nvarchar2,
                                        p_cust_rate out nvarchar2) as  curs rate.CUR_A;
  --curs2 rate.ratefree;
  v_cust_rate nvarchar2(32000) := 'mage';begin  open curs for '
   select cust_no||'',''||
           exch_code||'',''||
           vari_code||'',''||
           deliv_date||'',''||
           eo_commi_amt||'',''||
           eo_commi_rate||'',''||
           eo_add_fee1_amt||'',''||
           eo_add_fee1_rate||'',''||
           eo_add_fee2_amt||'',''||
           eo_add_fee2_rate||'',''||
           ot_commi_amt||'',''||
           ot_commi_rate||'',''||
           ot_add_fee1_amt||'',''||
           ot_add_fee1_rate||'',''||
           ot_add_fee2_amt||'',''||
           ot_add_fee2_rate||'',''||
           deliv_commi_amt||'',''||
           deliv_commi_rate||'',''||
           oper_code||'',''||
           oper_date||'',''||
           oper_time
      from SYB_CUST_COMMI
     where cust_no=:p_cust_no'
    using p_cust_no;  loop
    fetch curs
      into v_cust_rate;
    exit when curs%notfound;
    p_cust_rate := p_cust_rate || v_cust_rate || ',';
  
  end loop;  close curs;
  if v_cust_rate = 'mage' then
    open curs for '
                  select TEMPLATE_NO||'',''||
                         EXCH_CODE||'',''||
                         VARI_CODE||'',''||
                         DELIV_DATE||'',''||
                         EO_COMMI_AMT||'',''||
                         EO_COMMI_RATE||'',''||
                         EO_ADD_FEE1_AMT||'',''||
                         EO_ADD_FEE1_RATE||'',''||
                         EO_ADD_FEE2_AMT||'',''||
                         EO_ADD_FEE2_RATE||'',''||
                         OT_COMMI_AMT||'',''||
                         OT_COMMI_RATE||'',''||
                         OT_ADD_FEE1_AMT||'',''||
                         OT_ADD_FEE1_RATE||'',''||
                         OT_ADD_FEE2_AMT||'',''||
                         OT_ADD_FEE2_RATE||'',''||
                         DELIV_COMMI_AMT||'',''||
                         DELIV_COMMI_RATE||'',''||
                         OPER_CODE||'',''||
                         OPER_DATE||'',''||
                         OPER_TIME||'',''||
                         COMMI_TEMPLATE_ID
                    from SYB_COMMI_TEMPLATE
                   ';
    --where template_no=:p_cust_no
    --using p_cust_no;
  end if;  loop
    fetch curs
      into v_cust_rate;
    exit when curs%notfound;
    p_cust_rate := p_cust_rate || v_cust_rate || ',';
  
  end loop;  if v_cust_rate = 'mage' then
    p_cust_rate := 'MAGEHAOSHUAI';
  
  end if;
  --p_cust_rate:='aaaa';
  --close curs;end pre_allRate;