select into varchar2 和 nvarchar2

 

  1. create or replace procedure test_nvarchar2 is 
  2.   v_temp varchar2(999); 
  3. begin 
  4.   select t.father into v_temp from test1 t where t.father = 'wahah'
  5.   insert into test2 values (v_temp); 
  6. exception 
  7.   when no_data_found then 
  8.     dbms_output.put_line(v_temp); 
  9. end

 


 

  1. create or replace procedure test_nvarchar2 is 
  2.   v_temp nvarchar2(999); 
  3. begin 
  4.   select t.father into v_temp from test1 t where t.father = 'wahah'
  5.   insert into test2 values (v_temp); 
  6. exception 
  7.   when no_data_found then 
  8.     dbms_output.put_line(v_temp); 
  9. end

上下两段代码中,只有v_temp的类型不一样,一个是varchar2,另一个是nvarchar2,在使用nvarchar2时,在用pl/sql developer debug时,v_temp显示始终为null,尽管实际是有值的。而varchar2在debug时可以见值,不知道为什么,虽然结果都是能正确插入值到test2表中

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章