Oracle 動態數組使用-2

動態數組語法:

type <類型名> is table of 類型 index by binary_integer;
<變量名> 類型名

  • 示例:
declare 
  type jo_arr_type is table of pljson;  --jo_arr_type 爲表(數組)類型
  jo_arr jo_arr_type;  -- jo_arr 爲數組類型變量名
  type cur_ref_type is ref cursor; --聲明一個遊標引用類型  cur_ref_type
  cur cur_ref_type;  --聲明一個遊標引用類型變量
  i integer;
  ja pljson_listl;
  c clob;
begin
  i:=1;
  ja:=new pljson_list();
  open cur for 'select f1,f2 from tbname';
  for item in cur loop
    jo_arr(i):=new pljson();
	jo_arr(i).put('name',f1);
	jo_arr(i).put('value',f2);
	i:=i+1;
	...
	ja.append(jo_arr(i));
  end loop;
  dbms_lob.createtemporary(c,true);
  ja.to_clob(c);
  dbms_output.put_line(c);
end;
  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章