بتاريخ: 29 أبريل 200916 سنة comment_155215 ازاى من الاوراكل اقدر افتح ملف ورد واكتب فية داتا من الداتا بيزيعنى اعمل import للداتا بشكل معين لملف الورد دة تقديم بلاغ
بتاريخ: 29 أبريل 200916 سنة comment_155269 If you are using Developer 6i then use Text_IO package if you are using 10g or 9i the use CLIENT_TEXT_IO Package instead. Bellow are a document published from metalink -----------------------------------------------Subject: Read And Write Textfiles Using TEXT_IO Doc ID: 33247.1 Type: FAQ Modified Date: 06-JAN-2008 Status: PUBLISHED Checked for relevance on 06-Jan-2008Introduction============Oracle Forms V4.5 is the first version of the forms product that can access the packages of the PL/SQL Development Environment. Among these is the TEXT_IOpackage. By using TEXT_IO, forms developed under version 4.5 and higher can read and write to text files. This bulletin describes the code needed for commontext i/o tasks. The TEXT_IO Package===================The TEXT_IO package is described in the Development Environment User'sGuide and Reference (this may also be titled Procedure Builder User's Guide.)This document is included in electronic form when Oracle Forms is installed.Note that the files created by the TEXT_IO package are always stored in the client file system. Basic Structure===============Most routines for file I/O will follow a basic structure. For writes. this structure is: W1. Declare file handle. This is a variable which refers to the file. W2. Open the file for read/write in replace (W) or append (A) mode W3. Use TEXT_IO.PUT, PUTF, or PUT_LINE to write the data W4. Close the file W5. Exception handler to trap file errors For reading a file, the basic structure is: R1. Declare a file handle and a line buffer R2. Open the file in R mode R3. Within a loop, use TEXT_IO.GET_LINE to read data into line buffer R4. Process the data R5. Trap exception NO_DATA_FOUND to signify end of file. R6. Close the file R7. Exception handlers for other file errors. In the first few examples below, the code is marked W1-W5 and R1-R7 so you can see the application of this structure to real code. Do not enter theseinto your actual code.Preference Files================The following is a simple example of creating a form that maintainspreference information as flat files. A simple form is created thathas two preference text fields and a save button. The user will be able toenter values for these preferences, and the save button will write these todisk. On startup, the form reads the preference file and set the fieldsto the last saved values. 1. Create a new form. 2. Invoke the Layout Editor by selecting Tools -> Layout Editor. This creates a new canvas automatically. 3. Draw two text items and a push button. This creates a new block automatically. Name the block PREFS. Name the text items USERNAME and WINDOW_COLOR. Name the push button SAVE. 4. Create a WHEN-BUTTON-PRESSED trigger on the SAVE button. This writes the values in the fields out to a preference file called MYPREFS.TXT, in the form of <preference name>=<preference value>. DECLARE W1 MYFILE TEXT_IO.FILE_TYPE; BEGIN W2 MYFILE := TEXT_IO.FOPEN('MYPREFS.TXT','W'); W3 TEXT_IO.PUT_LINE(MYFILE, 'USERNAME='||:PREFS.USERNAME); W3 TEXT_IO.PUT_LINE(MYFILE, 'WINDOW_COLOR='||:PREFS.WINDOW_COLOR); W4 TEXT_IO.FCLOSE(MYFILE); EXCEPTION W5 WHEN OTHERS THEN MESSAGE('Preference file cannot be written'); END; 4. Create a WHEN-NEW-FORM-INSTANCE trigger on the form level. This trigger reads the values from the MYPREFS.TXT file into the preferences fields. DECLARE R1 MYFILE TEXT_IO.FILE_TYPE; R1 LINEBUF VARCHAR2(80); PREFNAME VARCHAR2(20); PREFVAL VARCHAR2(20); BEGIN R2 MYFILE := TEXT_IO.FOPEN('MYPREFS.TXT','R'); LOOP R3 TEXT_IO.GET_LINE(MYFILE, LINEBUF); R4 PREFNAME := SUBSTR(LINEBUF,1,INSTR(LINEBUF,'=')-1); R4 PREFVAL := SUBSTR(LINEBUF,INSTR(LINEBUF,'=')+1); R4 COPY(PREFVAL, 'PREFS.'||PREFNAME); END LOOP; EXCEPTION R5 WHEN NO_DATA_FOUND THEN R6 TEXT_IO.FCLOSE(MYFILE); R7 WHEN OTHERS THEN MESSAGE('Preferences file cannot be read'); END; 5. Run the form. The first time through, you receive an error because the preferences file does not yet exist. However, if on that first run you input some values for the two fields and press SAVE, on subsequent runs those preferences are loaded automatically. Error Handling==============As illustrated by the previous example, errors encountered when performingfile I/O are handled by the exception block. The NO_DATA_FOUND exceptionsignifies the end of a file when reading, but all other errors (file systemfull, file not found, etc.) raise the generic exception ORA 302000, which can be trapped by a when others exception handler.To discover the exact cause of a generic error, the PL/SQL Development Environment provides the TOOL_ERR package, which can winnow through theerror stack and return the error messages on the stack. At the time of thiswriting (Beta-2) the TOOL_ERR package is not available in Oracle Forms. However, it is planned. When it is available, it should show up under theBuilt-in Packages node of the Object Navigator.Here is an exception handler that displays the exact error messages thatoccurred: EXCEPTION WHEN OTHERS THEN IF SQLCODE = -302000 then LOOP EXIT WHEN TOOL_ERR.NERRORS = 0; MESSAGE(TO_CHAR(TOOL_ERR.CODE) || ': ' || TOOL_ERR.MESSAGE); TOOL_ERR.POP; END LOOP; END IF; Exporting a Block to a Flat File================================This example exports the current contents of the dept block to a flat file.Each record is on its own line, and the field values are separated bycommas. PROCEDURE WRITE_DEPT_BLOCK (FILENAME IN VARCHAR2) IS W1 MYFILE TEXT_IO.FILE_TYPE; BEGIN GO_BLOCK('DEPT'); IF :SYSTEM.BLOCK_STATUS != 'NEW' THEN FIRST_RECORD; W2 MYFILE := TEXT_IO.FOPEN(FILENAME, 'W'); LOOP W3 TEXT_IO.PUTF(MYFILE, '%s,%s,%s\n', TO_CHAR(:DEPT.DEPTNO), :DEPT.DNAME, :DEPT.LOC); EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE'; NEXT_RECORD; END LOOP; W4 TEXT_IO.FCLOSE(MYFILE); END IF; END; The example above uses the PUTF command, which inserts up to five values into a formatted string. In this example, the value of the deptno field takes the place of the %s, the value of dname takes the place of the second,etc. and the \n stands for a new line character. Thus, for the first record of dept, the following is written in the file: 10,ACCOUNTING,NEW YORK Note that the PUTF function has a limit of 5 arguments. If your block hasmore than 5 fields, you can use multiple PUTF statements. For example: TEXT_IO.PUTF('%s,%s,%s,%s,%s,', :F1, :F2, :F3, :F4, :F5); TEXT_IO.PUTF('%s, %s, %s\n', :F6, :F7, :F8); This technique is easily extended to master-detail blocks. Simply writeout the current master record information before entering the loop throughthe detail block. Importing a Text File into a Block==================================Importing from a text file is similar to the above, however, you must parse the comma-delimited files and retrieve the data bit by bit. For that you use a helper function, TOKEN, show below. FUNCTION TOKEN (LINEBUF IN OUT VARCHAR2) RETURN VARCHAR2 IS /* Returns the first token from the comma-delimited line */ /* passed as linebuf. Linebuf then has that token stripped */ /* so that subsequent calls return the second, third, etc. */ FIRST_TOKEN VARCHAR2(40); COMMA_POS NUMBER; BEGIN COMMA_POS := INSTR(LINEBUF, ','); IF COMMA_POS = 0 THEN FIRST_TOKEN := LINEBUF; LINEBUF := null; ELSE FIRST_TOKEN := SUBSTR(LINEBUF, 1, COMMA_POS - 1); LINEBUF := SUBSTR(LINEBUF, COMMA_POS + 1); END IF; RETURN FIRST_TOKEN; END; PROCEDURE READ_DEPT_BLOCK (FILENAME IN VARCHAR2) IS R1 MYFILE TEXT_IO.FILE_TYPE; R1 LINEBUF VARCHAR(255); BEGIN GO_BLOCK('DEPT'); CLEAR_BLOCK; R2 MYFILE := TEXT_IO.FOPEN(FILENAME, 'R'); LOOP R3 TEXT_IO.GET_LINE(MYFILE, LINEBUF); R4 :DEPT.DEPTNO := TO_NUMBER(TOKEN(LINEBUF)); R4 :DEPT.DNAME := TOKEN(LINEBUF); R4 :DEPT.LOC := TOKEN(LINEBUF); CREATE_RECORD; END LOOP; EXCEPTION R5 WHEN NO_DATA_FOUND THEN R6 TEXT_IO.FCLOSE(MYFILE); END IF; END; Importing a Text File into a Multi-Line Text Item=================================================The following procedure reads the contents of a plain text file intoa multi-line text item called Document. The file is assumed to be composed of 80-character lines terminated by a new line character. PROCEDURE READ_INTO_MULTI (FILENAME IN VARCHAR2) IS MYFILE TEXT_IO.FILE_TYPE; LINEBUF VARCHAR2(80); BEGIN MYFILE := TEXT_IO.FOPEN(FILENAME, 'R'); LOOP TEXT_IO.GET_LINE(MYFILE, LINEBUF); :DOCUMENT := :DOCUMENT || LINEBUF || CHR(10); END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN TEXT_IO.FCLOSE(MYFILE); END; The CHR(10) keeps the data in distinct lines in the multi-line output. Thisroutine should be used only for small to medium documents (that is, less than 32K). For importing larger documents, you should use SQL*Loader or custom user exits. Importing a Text File into a List Item======================================The following procedure reads the contents of a plain text file into a listitem called LISTITEM. The file is assumed to contain lines no longer than 80characters. The value and label of the list item are both set to the read-inline. DECLARE MYFILE TEXT_IO.FILE_TYPE; LINEBUF VARCHAR2(80); LINENO NUMBER := 1; BEGIN CLEAR_LIST('LISTITEM'); MYFILE := TEXT_IO.FOPEN('LISTFILE.TXT','R'); LOOP TEXT_IO.GET_LINE(MYFILE, LINEBUF); ADD_LIST_ELEMENT('LISTITEM', LINENO, LINEBUF, LINEBUF); LINENO := LINENO + 1; END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN TEXT_IO.FCLOSE(MYFILE); WHEN OTHERS THEN MESSAGE('Error while reading text file'); END; Audit Trail===========This example illustrates the technique of keeping a file open throughoutthe run of a form. You create a form that creates an audit file of a formsession, writing a header when the user logs in, a trailer when they exit the form, and, in between, keeps a record of DML transactions. 1. Create a new form. 2. Create a default block on the DEPT table. 3. Create a package spec. Click on the Program Units node of the Object Navigator and press insert. Fill in FILE_PKG as the name, and set Type to Package Spec. Enter the following as code: PACKAGE FILE_PKG IS MYFILE TEXT_IO.FILE_TYPE; END; 4. Create a form-level When-New-Form-Instance trigger. This opens the audit file on form startup and write the header. FILE_PKG.MYFILE := TEXT_IO.FOPEN('AUDIT', 'A'); TEXT_IO.PUTF(FILE_PKG.MYFILE, 'USER %s LOGGED ON, %s\n', USER, TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI')); 5. Create a form-level Post-Form trigger. This writes the log off information and closes the file. TEXT_IO.PUTF(FILE_PKG.MYFILE, 'USER %s LOGGED OFF, %s\n', USER, TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI')); TEXT_IO.FCLOSE(FILE_PKG.MYFILE); 6. Create a Pre-Delete trigger on the block level for DEPT block with the following code: TEXT_IO.PUTF(FILE_PKG.MYFILE, 'USER %s: DELETE RECORD\n', USER); TEXT_IO.PUTF(FILE_PKG.MYFILE, 'DEPTNO=%s, DNAME=%s, LOC=%s\n', TO_CHAR(:DEPTNO), :DNAME, :LOC); 7. Create a Pre-Insert trigger on the block level for DEPT block TEXT_IO.PUTF(FILE_PKG.MYFILE, 'USER %s: INSERT RECORD\n', USER); TEXT_IO.PUTF(FILE_PKG.MYFILE, 'DEPTNO=%s, DNAME=%s, LOC=%s\n', TO_CHAR(:DEPTNO), :DNAME, :LOC); 8. Create a Pre-Update trigger on the block level for DEPT block. The three triggers together audit all of the DML for the user TEXT_IO.PUTF(FILE_PKG.MYFILE, 'USER %s: UPDATE RECORD\n', USER); TEXT_IO.PUTF(FILE_PKG.MYFILE, 'DEPTNO=%s, DNAME=%s, LOC=%s\n', TO_CHAR(:DEPTNO), :DNAME, :LOC); 9. Now, each time the form is run, more information is added to the audit file. This example is not a solid auditing scheme, because it only works if one person logged on at a time, and this would only work for one client. However, it does illustrate the technique of keeping a file open across triggers by using package variables. References==========Note 257982.1 Using Webutil CLIENT_TEXT_IONote 352187.1 Character Set Problems with CLIENT_TEXT_IO versus TEXT_IO. تقديم بلاغ
بتاريخ: 1 مايو 200916 سنة comment_155464 you'll need to install webutility on your PC Subject: Using Webutil CLIENT_TEXT_IO Doc ID: 257982.1 Type: SAMPLE CODE Modified Date: 06-JAN-2008 Status: PUBLISHED Checked for relevance 06-Jan-2008REQUIREMENT =========== Ho to copy records from a form block into a text file in 9i/10g Forms. SOLUTION ======== CLIENT_TEXT_IO package of Webutil can be used to achieve this functionality. STEPS TO FOLLOW================1. Install and configure Webutil following instructions in the webutil manual and the readme file. 2. Create a form with a block (Example: DEPT)3. Create a button with the following code:declare MYFILE CLIENT_TEXT_IO.FILE_TYPE; CUR_REC NUMBER; FILENAME VARCHAR2(40):='c:\dept.txt'; BEGIN MYFILE := CLIENT_TEXT_IO.FOPEN(FILENAME, 'W'); go_block('dept'); first_record; CLIENT_TEXT_IO.PUTF(MYFILE,:deptno||' '||:dname||' '||:loc||'\n'); while (:system.last_record <> 'TRUE') loop next_Record; CLIENT_TEXT_IO.PUTF(MYFILE,:deptno||' '||:dname||' '||:loc||'\n'); end loop; CLIENT_TEXT_IO.FCLOSE(MYFILE); END; 4. Save the form and compile it. 5. Run the form. 6. Execute the query in the block. 7. Click on the button. 8. A text file will be created in the C: drive by the name dept.txtNote:-----The production release of WebUtil will be available with the first patchset for Oracle Application Server 10g (904).For more information on WebUtil, please refer to the following link: http://otn.oracle.com/products/forms/htdoc...til/webutil.htm تقديم بلاغ
بتاريخ: 1 مايو 200916 سنة comment_155465 Here's the steps of how to import the WEBUTIL in your application: --------------------------------------------------------Subject: How To Install Webutil on 10.1.2.x Oracle AS on Windows ? Doc ID: 566628.1 Type: HOWTO Modified Date: 22-OCT-2008 Status: PUBLISHED In this Document Goal Solution References--------------------------------------------------------------------------------Applies to: Oracle Forms - Version: 10.1.2MS WindowsMicrosoft Windows GoalHow to install WebUtil on 10.1.2.x OAS on Windows ?Solution1)- Download Webutil files from the following link: - Webutil version 1.0.6( With Oracle developersuite 10.1.2.2 or higher , webutil 10.1.2.2.x will be automatically installed !)It is not recommented to use with Forms 10.1.2.2 or higher webutil version 1.0.6 !- WebUtil Demo from OTN- The JACOB libraries version 1.8 2)- Create folder “webutil” under %ORACLE_HOME%\forms 3)- Copy the following files into %ORACLE_HOME%\forms\webutil :(a) jacob.dll ---> included in jacob_18.zip ( ffisamp.dll ---> included in Webutil_demo.zip © d2kwut60.dll ---> included in webutil_106.zip, under webutil subfolder (d) JNIsharedstubs.dll ---> included in webutil_106.zip, under webutil subfolder (e) sign_webutil.bat ---> included in webutil_106.zip, under webutil subfolder 4)- Copy the following files to %ORACLE_HOME%\forms\java : webutil_106\java \forms_base_ie.js webutil_106\java \forms_ie.js webutil_106\java \frmwebutil.jar jacob_18\jacob.jar 5)-Sign the "jacob.jar"as follows: - start the command prompt - cd %ORACLE_HOME%\forms\java - set PATH=%ORACLE_HOME%\jdk\bin;%PATH% - %ORACLE_HOME%\forms\webutil\sign_webutil.bat %ORACLE_HOME%\forms\java\jacob.jar 6)- Sign the "frmwebutil.jar"as follows: a)-For Forms 10.1.2.0.2:- start the command prompt - cd %ORACLE_HOME%\forms\java - set PATH=%ORACLE_HOME%\jdk\bin;%PATH% - %ORACLE_HOME%\forms\webutil\sign_webutil.bat %ORACLE_HOME%\forms\java\frmwebutil.jar -For Forms 10.1.2.2 or higher:1)-Get frmwebutil.jar from an Oracle Developer Suite installation which has the same version as the OAS and then ,copy it to“%ORACLE_HOME%\forms\java”. OR Get the frmwebutil.jar file from the Patchset 10.1.2.x kit as described in the following note and then ,copy it to “%ORACLE_HOME%\forms\java” : Note 421930.1 - How to get FRMWEBUTIL.JAR from IAS/IDS Patchset 10.1.2.x Kit 2)-Then, sign the frmwebutil.jar using the same steps as (6-a) .Explanation:frmwebutil.jar 1.0.6 is available for use with Forms versions 9.0.4 and 10.1.2.0.2. However,starting with Forms 10.1.2.2,the version of frmwebutil.jar has to be the same as the running Forms version . frmwebutil.jar 10.1.2.2 or higer is included with Patchset 10.1.2.x, which is the base release (10.1.2.0.2) plus a Patchset applied. This frmwebutil.jar version gets installed on Oracle Developer Suite Home when the Patchset is applied but not with Oracle AS Home .6)-Copy the following files from webutil_106\server to %ORACLE_HOME%\forms\server - webutil.cfg - webutilbase.htm - webutiljini.htm - webutiljpi.htm 7)- The following variable must be defined in %ORACLE_HOME%\forms\server\default.env: WEBUTIL_CONFIG=<ORACLE_HOME>\forms\server\webutil.cfg 8). The following jars must be included in the CLASSPATH in forms/server/default.env: %ORACLE_HOME%\forms\java\frmall.jar;%ORACLE_HOME%\forms\java\frmwebutil.jar;%ORACLE_HOME%\forms\java\jacob.jar;%ORACLE_HOME%\jdk\jre\lib\rt.jar 9)- The configuration file formsweb.cfg should have the following section : [webutil] WebUtilArchive=frmwebutil.jar,jacob.jar WebUtilLogging=off WebUtilLoggingDetail=normal WebUtilErrorMode=Alert WebUtilDispatchMonitorInterval=5 WebUtilTrustInternal=true WebUtilMaxTransferSize=16384 baseHTMLjinitiator=webutiljini.htm baseHTMLjpi=webutiljpi.htm archive_jini=frmall_jinit.jar archive=frmall.jar lookAndFeel=oracle 10)- The following virtual path must be defined in the %ORACLE_HOME%\forms\server\forms.conf file: AliasMatch ^/forms/webutil/(..*) "%ORACLE_HOME%/forms/webutil/$1" 11)- Open webutil.cfg file and add the following lineAdd the following line : install.syslib.0.user.1=ffisamp.dll|40960|1.0|true below : install.syslib.0.7.1=jacob.dll|94208|1.0|true install.syslib.0.9.1=JNIsharedstubs.dll|65582|1.0|true install.syslib.0.9.2=d2kwut60.dll|192512|1.0|true 12)- In the webutil.cfg file ensure you have the lines transfer.appsrv.workAreaRoot=d:\temp transfer.appsrv.accessControl=FALSE transfer.database.enabled=TRUE transfer.appsrv.enabled=TRUE 13)- Create a database user "Webutil" . 14)- Run the script "create_webutil_db.sql" (included in webutil_106.zip file). 15)- Create a file called d:\temp\downloaded_from_as.txt. Ensure you add text to this file.This is a test file which will be used to demonstrate loading files from the application server to the client.The Download test expects this file to exist in this location on the Application Server. 16)- Open forms builder and connect as "Webutil" user .Compile ALL" (shift-Control-K) form WU_TEST_106.fmb and webutil.pll ,then generate the fmx and plx using (Control-T).17)-Move the following files to %ORACLE_HOME%\forms : WU_TEST_106.fmx webutil plx webutil.olb © Run the Demo form WU_TEST_106 as the following to make sure that the installation went fine: http://host:port/forms/frmservlet?config=w...util/webutil@db (d) For more information ,go through the webutil documentation (specially "Runtime Setup Checklist" and "WebUtil Installation Steps").You will also find more describtion about the various webutil program units :Webutil Documentation 18)-You may also run the diagnostic test form described in the following note for furthur checking on the Webutil configuration : Note 553849.1Webutil Diagnostic Test Form For Checking Webutil Configuration ReferencesNote 333385.1 - Kickstarting WebUtil 1.06 in Developer Suite 10.1.2.0.2 on WindowsNote 374128.1 - How To Install Webutil on OAS under Linux/UnixNote 421930.1 - How To Get FRMWEBUTIL.JAR From IAS/IDS Patchset 10.1.2.x KitNote 553849.1 - Webutil Diagnostic Test Form For Checking Webutil Configurationhttp://java.sun.com/javase/downloads/index.jspKeywordsWEBUTIL ; FRMWEBUTIL.JAR ; --------------------------------------------------------------------------------Help us improve our service. Please email us your comments for this document. . تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.