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表中

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