Oracle UTL_FILE 用法例子
General Information | |
Note: O/S permissions are those of the user 'Oracle' ... not the schema owner or connected user | |
Source | {ORACLE_HOME}/rdbms/admin/utlfile.sql |
First Availability | 7.3.4 |
init.ora Parameters | utl_file_dir | ||||||||||||
utl_file_dir=c:/oraload utl_file_dir=c:/temp utl_file_dir=* |
|||||||||||||
Open Modes |
|
FCLOSE | |
Close A File Opened By UTL_FILE | utl_file.fclose(<file_handle>) |
see FOPEN demo | |
FCLOSE_ALL | |
Close All Files Opened By UTL_FILE | utl_file.fclose_all; |
set serveroutput on DECLARE vInHandle utl_file.file_type ; vOutHandle utl_file.file_type ; BEGIN vInHandle := utl_file.fopen ('ORALOAD', 'test.txt', 'R'); vOutHandle := utl_file.fopen ('ORALOAD', 'out.txt', 'W'); IF utl_file.is_open utl_file.fclose_all ; dbms_output.put_line('Closed All'); END IF; END fopen; / |
|
FCOPY | |
Copies a contiguous portion of a file to a newly created file | utl_file.fcopy ( location IN VARCHAR2, filename IN VARCHAR2, dest_dir IN VARCHAR2, dest_file IN VARCHAR2, start_line IN PLS_INTEGER DEFAULT 1, end_line IN PLS_INTEGER DEFAULT NULL); |
-- demo requires creating directory CTEMP ... see link at bottom of page BEGIN utl_file.fcopy ('ORALOAD', 'dump.txt', 'ORALOAD', 'didit.txt'); END; / |
|
FFLUSH | |
Physically writes pending data to the file identified by the file handle | utl_file.fflush (<file_handle>); |
See Write demo | |
FGETATTR | |
Reads and returns the attributes of a disk file | utl_file.fgetattr( location IN VARCHAR2, filename IN VARCHAR2, exists OUT BOOLEAN, file_length OUT NUMBER, blocksize OUT NUMBER); |
set serveroutput on DECLARE ex BOOLEAN; flen NUMBER; bsize NUMBER; BEGIN utl_file.fgetattr ('ORALOAD', 'test.txt', ex, flen, bsize); IF ex THEN dbms_output.put_line('File Exists'); ELSE dbms_output.put_line('File Does Not Exist'); END IF; dbms_output.put_line('File Length: ' || TO_CHAR(flen)); dbms_output.put_line('Block Size: ' || TO_CHAR(bsize)); END fgetattr; / |
|
FGETPOS | |
Returns the current relative offset position within a file, in bytes | utl_file.fgetpos(fileid IN file_type) RETURN PLS_INTEGER; |
See Read-Write demo | |
FOPEN | |
Open A File For Read Operations | utl_file.fopen( <file_location IN VARCHAR2>, <file_name IN VARCHAR2>, <open_mode IN VARCHAR2>, <max_linesize IN BINARY_INTEGER>) RETURN <file_type_package_data_type; |
DECLARE vInHandle utl_file.file_type ; vNewLine VARCHAR2(250); BEGIN vInHandle := utl_file.fopen ('ORALOAD', 'test.txt', 'R'); LOOP BEGIN utl_file.get_line (vInHandle, vNewLine); dbms_output.put_line(vNewLine); EXCEPTION WHEN OTHERS THEN EXIT; END; END LOOP; utl_file.fclose (vInHandle); END fopen; / |
|
Open A File For Write Operations | <file_handle> := utl_file.fopen(<file_location, file_name, 'w ') |
FOPEN_NCHAR | |
Open a file to read or write a text file in Unicode instead of in the database charset | |
FREMOVE | |
Delete An Operating System File | utl_file.fremove (location IN VARCHAR2, filename IN VARCHAR2); |
BEGIN utl_file.fremove ('ORALOAD', 'dump.txt'); END fremove; / |
|
FRENAME | |
Rename An Operating System File | utl_file.frename ( location IN VARCHAR2, filename IN VARCHAR2, dest_dir IN VARCHAR2, dest_file IN VARCHAR2, overwrite IN BOOLEAN DEFAULT FALSE); |
BEGIN utl_file.frename ('ORALOAD','test.txt','ORALOAD','x.txt',TRUE); END frename; / |
|
FSEEK | |
Adjusts the file pointer forward or backward within the file by the number of bytes specified | utl_file.fseek ( fid IN utl_file.file_type, absolute_offset IN PL_INTEGER DEFAULT NULL, relative_offset IN PLS_INTEGER DEFAULT NULL); |
See Read-Write demo | |
GETLINE | |
Read a Line from a file | utl_file.getline ( file IN FILE_TYPE, buffer OUT VARCHAR2, linesize IN NUMBER, len IN PLS_INTEGER DEFAULT NULL); |
See Read demos | |
GETLINE_NCHAR | |
Same as GETLINE except can be used to read Unicode rather than the database's character set | |
GET_RAW | |
Reads a RAW string value from a file and adjusts the file pointer ahead by the number of bytes read | utl_file.get_raw ( fid IN utl_file.file_type, r OUT NOCOPY RAW, len IN PLS_INTEGER DEFAULT NULL); |
See UTL_MAIL demo | |
IS_OPEN | |
Returns True If A File Handle Is Open: Otherwise False | utl_file.is_open (file IN FILE_TYPE) RETURN BOOLEAN; |
See FCLOSE_ALL Demo | |
NEW_LINE | |
Writes one or more operating system-specific line terminators to a file | utl_file.NEW_LINE (file IN FILE_TYPE, lines IN NATURAL := 1); |
See Read Demo | |
PUT | |
Writes a string to a file | utl_file.put( file IN FILE_TYPE, buffer IN VARCHAR2); |
See Write demo | |
PUTF | |
A PUT procedure with formatting | utl_file.putf( file IN FILE_TYPE, format IN VARCHAR2, [arg1 IN VARCHAR2 DEFAULT NULL, . . . arg5 IN VARCHAR2 DEFAULT NULL]); |
See Write demo | |
PUT_LINE | |
Writes a line to a file. Appends an operating system-specific line terminator | utl_file.put_line( file IN FILE_TYPE, buffer IN VARCHAR2, autoflush IN BOOLEAN DEFAULT FALSE); |
See Read-Write demo | |
PUT_NCHAR | |
Writes a Unicode string to a file | |
PUT_RAW | |
Accepts as input a RAW data value and writes the value to the output buffer | utl_file.PUT_RAW ( fid IN utl_file.file_type, r IN RAW, autoflush IN BOOLEAN DEFAULT FALSE); |
See extract_blob Demo | |
PUT_LINE_NCHAR | |
Writes a Unicode line to a file | |
PUTF_NCHAR | |
Writes a Unicode string to a file |
轉自 http://hi.baidu.com/edeed/blog/item/ac8a36d39a40ea043af3cfa6.html
相關推薦
Oracle UTL_FILE 用法例子
2008-01-27 17:48 General Information Note: O/S permissions are those of the user 'Oracle' ... not the schema owner or connect
Oracle expdp/impdp 用法例子 詳解 舉例 例子 他的這篇文章沒有辦法寫出來 要這麼改
在之前的blog: Oracle 10g Data Pump Expdp/Impdp 詳解 exp/imp 與 expdp/impdp 對比及使用中的一些優化事項 中對資料泵這塊的理論知識有一些說明,但是沒有實際操作的例子。 所以在這裡就對expdp/im
oracle nologging用法(轉)
而是 array 類型 無效 data 還得 模式 dddd reat 一、oracle日誌模式分為(logging,force logging,nologging) 默認情況是logging,就是會記錄到redo日誌中,force logging是強制記錄日誌,nolog
oracle ROW_NUMBER用法
Oracle中row_number()、rank()、dense_rank() 的區別 row_number的用途非常廣泛,排序最好用它,它會為查詢出來的每一行記錄生成一個序號,依次排序且不會重複 使用ow_number函式時必須要用over子句選擇對某一列進行排序才能生成序號。 eg:取出表A中第31到
tensorflow tf.argmax() 用法 例子
轉自:https://blog.csdn.net/Jiaach/article/details/78874704 argmax()官方文件如下: tf.argmax(input, dimension, name=None) Returns the index with t
oracle cascade用法
級聯刪除,比如你刪除某個表的時候後面加這個關鍵字,會在刪除這個表的同時刪除和該表有關係的其他物件 1.級聯刪除表中的資訊,當表A中的欄位引用了表B中的欄位時,一旦刪除B中該欄位的資訊,表A的資訊也自動刪除。(當父表的資訊刪除,子表的資訊也自動刪除) 例如下面這兩個表中分別存的時員工的
oracle like %% 用法
<select id="selectByExampleAll" resultMap="BaseResultMap" parameterType="com.hongwan.web.dao.entity.FRM_CLXX" > select * from FRM_CLXX wh
oracle sqlldr 用法詳解
轉自:http://blog.chinaunix.net/uid-23622436-id-2394093.html 在 Oracle 資料庫中,我們通常在不同資料庫的表間記錄進行復制或遷移時會用以下幾種方法: 1. A 表的記錄匯出為一條條分號隔開的 insert 語句,然
Oracle Exists用法
(一) 用Oracle Exists替換DISTINCT: 當提交一個包含一對多表資訊(比如部門表和僱員表)的查詢時,避免在SELECT子句中使用DISTINCT。一般能夠考慮用Oracle EXIST替換,Oracle Exists使查詢更為迅速,因為RDBMS核
C define用法例子
#include <iostream> using namespace std; /* 規則1: 用巨集定義表示式時,要使用完備的括號。 #define RECTANGLE_AREA(a, b) ((a) * (b)) 規則2: 規則5.2 將巨集所定義的多條表示
oracle的用法
在Oracle資料庫內有一種特殊的表Dual。Dual表是Oracle中的一個實際存在的表,任何使用者均可讀取,常用在沒有目標表的Select中。Dual表由Oracle連同資料字典一同建立,所有的使用者都可以用名稱DUAL訪問該表。這個表裡只有一列DUMMY,該列定義為VA
Oracle decode 用法
DECODE用法: DECODE(value,if1,then1,if2,then2,if3,then3,...,else) 含義為: if 條件=
總結Intent的用法例子
-----呼叫撥號程式 // 給移動客服10086撥打電話 Uri uri = Uri.parse("tel:10086"); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent
Oracle Procedure 用法
1、建立儲存過程 create or replace procedure test(var_name_1 in type,var_name_2 out type) as --宣告變數(變數名 變數型別) begin --儲存過程的執行體 end test; 打印
如何配置Tomcat的JNDI (以oracle資料庫為例子)
定義:JNDI(Java Naming and Directory Interface,Java命名和目錄介面) 是一組在Java應用中訪問命名和目錄服務的API 1. Install Your JDBC Driver 把ojdbc14.jar放入Tomcat的li
Oracle中distinct的用法例項以及Oracle distince 用法和刪除重複資料
Oracle中distinct的用法例項 摘要: 此外,distinct 會對返回的結果集進行排序 所以會大大影響查詢效率,大資料集時比較明顯 。所以,最好和order by 結合使用,可以提高效率 。 select distinct a,b,c from t;表t裡列
Oracle union用法
UNION 指令的目的是將兩個 SQL 語句的結果合併起來,可以檢視你要的查詢結果. 例如: SELECT Date FROM Store_Information UNION SELECT Date FROM Internet_Sales 注意:union用法中,兩個select語句的欄位型別匹配,而且欄位個
oracle minus用法
Oracle Minus關鍵字 SQL中的MINUS關鍵字 SQL中有一個MINUS關鍵字,它運用在兩個SQL語句上,它先找出第一條SQL語句所產生的結果,然後看這些結果有沒有在第二個SQL語句的結果 中。如果有的話,那這一筆記錄就被去除,而不會在最後的結果中出現。如果第二個SQL語句所產生的結果並沒有存
[資料庫] Navicat for Oracle基本用法(匯入匯出正刪改查)圖文介紹
引自百度百科:Navicat for Oracle是一套超強的Oracle資料庫系統管理工具。它有極具巧思的圖形化使用者介面(GUI),讓你可以快速且容易的以安全且簡單的方法建立、組織、存取及共享資訊。Navicat for Oracle可以讓使用者連線本地/遠端Oracl
[AttributeUsage(AttributeTargets.Class)] 用法例子
首先,建立一個自定義的Attribute,並且事先設定我們的Attribute將施加在class的元素上面以獲取一個類程式碼的檢查資訊。 using System; using System.Reflection; [AttributeUsage(AttributeT