導航:首頁 > 文件教程 > 存儲過程上傳文件

存儲過程上傳文件

發布時間:2025-01-05 11:52:03

A. 如何把oracle 存儲過程 輸出到文本

分幾個步驟
1,創建輸出路徑,比如你要在c盤test目錄下輸出,你就先要建立好這個test路徑

2,sqlplus下以sysdba登錄,執行以下語句

3,create or replace directory TMP as 'c: est'

4,grant read,write on directory TMP to 你要生成文件的用戶;

5,alter system set utl_file_dir='c: est' scope=spfile;
以上步驟執行完,需要重啟資料庫

6,最重要的一步開始了,創建存儲過程

createorreplacePROCEDURESP_OUTPUT
is
file_handleutl_file.file_type;
Write_contentVARCHAR2(1024);
Write_file_nameVARCHAR2(50);
v_idint;
v_formvarchar2(10);
cursorcur_sp_out
is
selectid,formfroma;
begin
opencur_sp_out;
loop
fetchcur_sp_outintov_id,v_form;
exitwhencur_sp_out%notfound;
write_file_name:=to_char(SYSDATE,'MMDD')||'.txt'
file_handle:=utl_file.fopen('TMP',write_file_name,'a');
write_content:=v_id||''||v_form;
--writefile
IFutl_file.is_open(file_handle)THEN
utl_file.put_line(file_handle,write_content);
ENDIF;
--closefile
utl_file.fclose(file_handle);
endloop;
closecur_sp_out;
end;


我建立了一個跟你一樣的測試表,數據如下
createtablea(idint,
formvarchar2(10));

insertintoavalues(1,'你好');
insertintoavalues(2,'你很好');


然後執行存儲過程
begin
SP_OUTPUT;
end;


執行完畢後,你在c盤test路徑下會發現已經有新文件生成


文件內容


存儲過程的話,如果表名和欄位名跟你一致的話,你無須修改

閱讀全文

與存儲過程上傳文件相關的資料

熱點內容
ps3文件分割視頻 瀏覽:280
微信圖片一鍵轉發軟體 瀏覽:331
如何判斷s200plc編程電纜 瀏覽:691
太原編程培訓班哪個好 瀏覽:171
樹葉吹奏教程 瀏覽:6
社交app帶來了哪些社會問題 瀏覽:394
如何安裝愛寶8800數據採集器 瀏覽:712
文件保存了怎麼找不到了 瀏覽:476
彩票網站怎麼辨真假 瀏覽:840
pr找不到該文件 瀏覽:963
java移除panel 瀏覽:354
jsp填充jsp 瀏覽:166
海關外貿大數據在哪裡查 瀏覽:381
思特奇java筆試題 瀏覽:121
葫蘆俠在手機中的文件名 瀏覽:813
plc編程應該怎麼收錢 瀏覽:584
c語言中源文件由什麼組成 瀏覽:890
linuxhttpdphp配置文件 瀏覽:607
拆單數據要怎麼保存 瀏覽:17
mac電腦怎樣壓縮文件到100m 瀏覽:645

友情鏈接