Write data using utl_file
hi , i am using oracle 10g.
i am writing this job which runs every day and writes into file.
first time i has to put upto 700,000 records into file and from next run it will be around 5000.
please let me know what ever i am doing is correct or not. i never used utl_file , since this is my first time using utl_file i really need help from you guys.
CREATE OR REPLACE PROCEDURE pr_cpe_dashboard
IS
CURSOR c1
IS
SELECT /*+ parallel ( qdm 8) index(sdm INDX_RPRE_MART_SITE_QREV) index(odm INDX_RPRE_MART_ORD_QSITE) */
qdm.quote_id
|| '||'
|| qdm.quote_revision
|| '||'
|| qdm.quote_status
|| '||'
|| qdm.last_modified_date
|| '||'
|| qdm.billing_method
|| '||'
|| qdm.quote_total
|| '||'
|| CASE
WHEN sdm.project_number IS NULL
THEN 'NULL'
ELSE sdm.project_number
END
|| '||'
|| CASE
WHEN odm.order_number IS NULL
THEN 'NULL'
ELSE odm.order_number
END
|| '||'
|| CASE
WHEN odm.order_type IS NULL
THEN 'NULL'
ELSE odm.order_type
END
|| '||'
|| CASE
WHEN odm.release_timestamp IS NULL
THEN 'NULL'
ELSE TO_CHAR (odm.release_timestamp, 'mm/dd/yyyy hh:mi:ss')
END
|| '||'
|| CASE
WHEN sdm.account_name IS NULL
THEN 'NULL'
ELSE sdm.account_name
END
|| '||'
|| qdm.nasp_id
FROM r_premisys_quote_detail_mart qdm,
r_premisys_site_detail_mart sdm,
r_premisys_order_detail_mart odm
WHERE qdm.quote_id = sdm.quote_id(+)
AND qdm.quote_revision = sdm.quote_revision(+)
AND qdm.quote_id = odm.quote_id(+)
AND qdm.quote_revision = odm.quote_revision(+)
AND qdm.last_modified_date >= (SELECT last_used_date
FROM job_audit_date);
output_file UTL_FILE.file_type;
l_dir VARCHAR2 (10) := 'c:/orders';
l_filename VARCHAR2 (25) := 'cpe.txt';
v_array t_array := t_array ();
BEGIN
output_file := UTL_FILE.fopen (l_dir, l_filename, 'W');
OPEN c1;
LOOP
FETCH employees_cur
BULK COLLECT INTO v_array LIMIT 1000;
FOR i IN 1 .. v_array.COUNT
LOOP
UTL_FILE.put_line (output_file, v_array (i));
END LOOP;
EXIT WHEN v_array.COUNT = 0;
END LOOP;
UTL_FILE.fclose (output_file);
END pr_cpe_dashboard;
A couple of things.
This is wrong:
l_dir VARCHAR2 (10) := 'c:/orders';It must be the name of a directory object, created via the "+CREATE DIRECTORY+" command. Dir objects are (database) aliases for physical paths. Like any other db object, it provides a security layer that allows one to control access to it. You do not want any and all db sessions to access the root drive on that server.
Not necessary:
v_array t_array := t_array ();You are calling the constructor to create an empty array. Not needed as the bulk collect does that for you. Simply define the variable - the bulk collect takes the responsibility for initialising and populating it.
Review:
parallel ( qdm 8) Personally I dislike such hints, hints forcing indexes and so on. Reason is that the developer is second guessing the CBO. Yes, you may have the right values for the development db and its data set. It may even work for production for a while. But production is very seldom static. Process loads varies. Data volumes increases. Even the database model changes (e.g. new columns, new indexes, etc). H/w changes (e.g. more CPUs, more memory, etc).
By second guessing the CBO, the developer makes it very hard for the DBA and CBO properly manage performance and scalability on the server.
Also, keep in mind that UTL_FILE (and PL/SQL code) is a serialised process (only exception is specially crafted pipeline table functions). So despite using/requesting 8 parallel query processes (PQ) in the hint, a single PL process has to write that data to file. Be sure that you identify the appropriate bottleneck when dealing with I/O and wanting to use PQ to address it.
Similar Messages
-
Spooling large data using UTL_FILE
Hi Everybody!
While spooling out data into a file using UTL_FILE package I am unable spool the data The column data has a size of 2531 characters
The column 'source_where_clause_text' has very large data.
Its not giving any error but the external table is not returning and data
Following is the code.
CREATE OR REPLACE PROCEDURE transformation_utl_file AS
CURSOR c1 IS
select transformation_nme,source_where_clause_text
from utility.data_transformation where transformation_nme='product_closing';
v_fh UTL_FILE.file_type;
BEGIN
v_fh := UTL_FILE.fopen('UTLFILELOAD', 'transformation_data.dat', 'w', 32000);--132767
FOR ci IN c1
LOOP
UTL_FILE.put_line( v_fh, ci.transformation_nme ||'~'|| ci.source_where_clause_text);
-- UTL_FILE.put_line( v_fh, ci.system_id ||'~'||ci.system_nme ||'~'|| ci.system_desc ||'~'|| ci.date_stamp);
END LOOP;
UTL_FILE.fclose( v_fh );
exception
when utl_file.invalid_path then dbms_output.put_line('Invalid Path');
END;
select length(
'(select to_char(b.system_id) || to_date(a.period_start_date,''dd-mon-yyyy'') view_key, b.system_id, to_date(a.period_start_date,''dd-mon-yyyy'') period_start_date, to_date(a.period_end_date,''dd-mon-yyyy'') period_end_date, to_date(a.clos
ing_date,''dd-mon-yyyy'') closing_date from ((select decode(certification_type_code, ''A'', ''IDESK_PRODUCTS_PIPELINE'',''C'', ''IDESK_PRODUCTS_COMMITMENT_LINKAGE'') system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyy
yy''),''dd-mon-yyyy'') period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsu
pload.prod_monthly_certification where certification_type_code in (''A'',''C'') minus select trim(system_nme), to_char(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing
statusv where system_nme in (''IDESK_PRODUCTS_PIPELINE'', ''IDESK_PRODUCTS_COMMITMENT_LINKAGE'')) union all (select ''BMS Commitment Link'' system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy''),''dd-mon-yyyy'')
period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsupload.prod_monthly_c
ertification where certification_type_code = ''C'' minus select trim(system_nme), to_char(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing_status_v where system_nme
= ''BMS Commitment Link'') union all (select ''BMS'' system_nme, to_char(to_date(''01'' || lpad(trim(to_char(certification_as_of_month_yr)),6,''0''),''ddmmyyyy''),''dd-mon-yyyy'') period_start_date, to_char(last_day(to_date(''12'' || lpad(trim(to_char(certification_as_
of_month_yr)),6,''0''),''ddmmyyyy'')),''dd-mon-yyyy'') period_end_date, to_char(trunc(certification_datetime_stamp), ''dd-mon-yyyy'') closing_date from odsupload.prod_monthly_certification where certification_type_code = ''A'' minus select trim(system_nme), to_char
(period_start_date, ''dd-mon-yyyy''), to_char(period_end_date, ''dd-mon-yyyy''), to_char(closing_date, ''dd-mon-yyyy'') from utility.system_closing_status_v where system_nme = ''BMS'')) a, utility.system_v b where a.system_nme = b.system_nme)') length1
from dual
--2531
begin
SSUBRAMANIAN.transformation_utl_file;
end;
create table transformation_utl
TRANSFORMATION_NME VARCHAR2(40),
SOURCE_WHERE_CLAUSE_TEXT VARCHAR2(4000)
ORGANIZATION external
type oracle_loader
default directory UTLFILELOAD
ACCESS PARAMETERS
records delimited by newline CHARACTERSET US7ASCII
BADFILE UTLFILELOAD:'transformation.bad'
LOGFILE UTLFILELOAD:'transformation.log'
fields TERMINATED by "~"
LOCATION ('transformation_data.dat')
) REJECT LIMIT UNLIMITED
select * from transformation_utlafter running the procedure, did you verify that the file 'transformation_data.dat' has data? open it, make sure it's correct. maybe it has no data, and that's why the external table doesn't show anything.
also, check the LOG and BAD files after selecting from the external table. maybe they have ERRORS in them (or all the data is going to BAD because you defined something wrong). -
How to upload data using utl_file when you dont know the exact file name
Hi
i want to upload data from a flat file to a table.
i dont know the exact file name. i want to make a search for filename. like i want to make a search on file (say test*) which will give me all the files with test.
i want to upload data using these files.
how can i do this by using UTL_FILE.
Regards
ManishThank you very much.
Thing is previously we are using sqlloader and shell script for loading the data.
now i am creating a procedure (if possible without parameters).
Is there any other way i can do that.
can i make a wild card search using utl_file.
Thanks n Regards
Manish -
Writing CLOB data using UTL_FILE to several files by settingmaxrows in loop
Hey Gurus,
I have a procedure that creates a CLOB document (in the form of a table in oracle 9i). I need to now write this large CLOB data (with some 270,000 rows) into several files, setting the row max at 1000. So essentially ther would be some sort of loop construct and substr process that creates a file after looping through 1000 rows and then continues the count and creates a another file until all 270 xml files are created. Simple enough right...lol? Well I've tried doing this and haven't gotten anywhere. My pl/sql coding skills are too elementary I am guessing. I've only been doing this for about three months and could use the assistance of a more experienced person here.
Here are the particulars...
CLOB doc is a table in my Oracle 9i application named "XML_CLOB"
Directory name to write output to "DIR_PATH"
DIRECTORY PATH is "\app\cdg\cov"
Regards,
Christhe xmldata itself in the CLOB would look like this for one row.
<macess_exp_import_export_file><file_header><file_information></file_information></file_header><items><documents><document><external_reference></external_reference><processing_instructions><update>Date of Service</update></processing_instructions><filing_instructions><folder_ids><folder id="UNKNOWN" folder_type_id="19"></folder></folder_ids></filing_instructions><document_header><document_type id="27"></document_type><document_id>CUE0000179</document_id><document_description>CUE0000179</document_description><document_date name="Date of Service">1900-01-01</document_date><document_properties></document_properties></document_header><document_data><internal_file><document_file_path>\\adam\GiftSystems\Huron\TIFS\066\CUE0000179.tif</document_file_path><document_extension>TIF</document_extension></internal_file></document_data></document></documents></items></macess_exp_import_export_file> -
Error while using UTL_FILE.FOPEN
sir,
when i write procedure using utl_file.fopen i am getting error as it must be declared PLS-00201. what mistake, i am doing.
yours
dr.s.r.bhattachari was under the impression that there will be a moderator who will redirect the question even by mistake we post? is it not?Absolutely not. On the APEX forum we are in the fortunate position of having members of Oracle's APEX team actively involved, but neither they nor any of the other contributors perform the role of moderator or have administrative access to the forum system. The OTN team who do only really perform "moderation" when there has been a breach of the OTN Terms and Conditions.
If your question has obviously been posted in the wrong forum, or someone thinks you will get a better response elsewhere then generally they'll suggest this, as above. -
CSV file reading using UTL_FILE at run time
Hi,
I have to read CSV file using UTL_FILE.
but Folder contains Many CSV files.
I dont know there name.So i have to read csv file at run time.
Please let me know how should we achieve this?
Thanksplace the following in a shell script, say "list_my_files.ksh"
ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
begin
dbms_scheduler.create_program (program_name => 'a_test_proc'
,program_type => 'EXECUTABLE'
,program_action => '/home/bluefrog/list_my_files.ksh'
,number_of_arguments => 0
,enabled => true);
end;
/then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
P; -
Error writing data in a flat file using UTL_FILE feature
Hi All,
I have written a package which fetches data from four different cursors and inserts into a temporary table.
Now this temporary table is used to write data in a file using the UTL_FILE feature.
fhandler :=
UTL_FILE.fopen (l_path,'Demand_Transactions_'
|| TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
|| '.txt',
'w',
max_linesize => 32767
This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.
Any help in this would be highly appreciated.
Regards,
Shruti891330 wrote:
Hi All,
I have written a package which fetches data from four different cursors and inserts into a temporary table.
Now this temporary table is used to write data in a file using the UTL_FILE feature.
fhandler :=
UTL_FILE.fopen (l_path,'Demand_Transactions_'
|| TO_CHAR (SYSDATE, 'YYYYMMDDHH24MI')
|| '.txt',
'w',
max_linesize => 32767
This table has 62593 records and when it starts writing data into the file from the table it errors out after writing 30045 records with the error - ORA-01722: invalid number.
Can anyome please advise me is it because of the max_linesize => 32767. If not then what can be the possible reason.Max linesize is the number of characters in a line before a newline has to be issued, not the number of rows written.
The error would indicate that you have a character to number conversion going on somewhere but the characters are not numeric so it's failing that conversion.
This doesn't sound like a UTL_FILE issue, but more to do with how you are building up your strings to output to the file.
You would need to show us your code that builds up the lines you are writing out, with details of the datatypes of any of the columns/variables included in that. -
HOW TO READ DATA FROM A FILE AND INSERT INTO A TABLE USING UTL_FILE
Hi..
I have a file.I want to read the data from file and load it into a table using utl_file.
how can I do it?
Any reply apreciated...Hi,
This is not your requirment but u can try this :
CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
GRANT READ ON DIRECTORY text_file TO fah;
GRANT WRITE ON DIRECTORY text_file TO fah;
DROP TABLE load_a;
CREATE TABLE load_a
(a1 varchar2(20),
a2 varchar2(200))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY text_file
ACCESS PARAMETERS
(FIELDS TERMINATED BY ','
LOCATION ('data.txt')
select * from load_a;
CREATE TABLE A AS select * from load_a;
SELECT * FROM A
Regards
Faheem Latif -
How to write data to text file using external tables
can anybody tell how to write data to text file using external tables concept?
Hi,
Using external table u can load the data in your local table in database,
then using your local db table and UTL_FILE pacakge u can wrrite data to text file
external table
~~~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
UTL_FILE
~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
Message was edited by:
Nicloei W
Message was edited by:
Nicloei W -
How to read a tab seperated data from a text file using utl_file
Hi,
How to read a tab seperated data from a text file using utl_file...
I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
Thanks in advance...
NaveenNaveen Nishad wrote:
How to read a tab seperated data from a text file using utl_file...
I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead. -
How to write data in the Infocube using BI IP input ready functionality
Hi All,
Please help me in the following scenario...
Input given to me is-- ZCUBSDID cube with associated role ZSP_BW_SAI_BUDGETS-DID_ALL.
Query is ZR_V7_CO_PA_CH_PB_DID_BUDGET_2 based on agregation level ZALBSDID (& ZALBVDID) in infoarea ZDACOPA.
I have to write data in the cube by using Input-Ready functionality of BI IP. Can you please provide me step by step procedure for writing the data in the cube as i am very new in IP side.
Also if any further input required just let me know.
My Analysis-> I checked that cube is in Planning mode and in Query Designer>Property Pane-->Planning Pane, Query is in Change mode and also associated Keyfigures are in Input-Ready enabled.
Also i am able to access query in Analyzer.
This is very critical for me and need to provide solution asap. Please update asap. It really be great help.
Thanks & Regards
Rupali SinghHi,
To enter data in to planning cube through manual planning, you can do the following,
1. In a query that is used for manual planning, a cell is only input ready if each characteristic value of all the characteristics included in the aggregation level is unique. None of the aggregated values on the aggregation level are therefore input ready: Totals, subtotals and inner hierarchy nodes are not input ready.
2. To be able to change values for calculated key figures (like Average Price as a quotient of Amount and Quantity), these must be based on input-ready formulas, and at least one operand must be input ready. More information: Defining Inverse Formulas (Designtime) and Inverse Formulas (Runtime).
3. In order to change aggregated values (with respect to the aggregation level), these values must be disaggregated on all the data records that contribute to the aggregated value of the cell. More information: Disaggregation (Top-Down-Distribution).
4. If a query used for manual planning includes a navigation attribute that is restricted using a fixed or dynamic filter or a restricted key figure, the system treats the navigation attribute as a normal characteristic. The rule under point 1 applies here. The system only reacts as though the navigation attribute were not part of the query if the navigation attribute is not restricted.
5. In a query defined on a MultiProvider or a complex aggregation level that you want to use manual planning for, a cell is not input ready if the InfoProvider that is defined by this cell is:
a. Not a real-time InfoCube
b. A real-time InfoCube that has been switched to load mode
6. If an input-ready query is executed in change mode, but the requested data is locked by another user, the query starts in display mode.
For more details, you can refer to the following link,
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/0c033316cd2bc4e10000000a114cbd/frameset.htm
Hope this helps you to solve your issue.
Regards,
Balajee -
Using Swing applet to write data to file on SERVER
Hello,
I'm in the process of writing an applet using Swing (SDK v1.4.2). Here's the deal. The JApplet calls a JPanel, which will be used by customers on my site to enter data. I'm adding a <Save> button to the "form" which is supposed to write data to a file on the server (in order to preserve the customer's preferences).
Please note that I am NOT attempting to write data to the customer's hard disk. That requires digital certificates, etc. which I am trying to avoid for now.
Instead, I am using the URL class to access the file:
URL page = new URL("http://www.whatever.com/mycustomers/preferences.txt")
I then use the URLConnection class to establish the connection:
URLConnection conn = this.page.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
etc...
I've created a text file (preferences.txt) on my web site. Using the classes InputStreamReader, BufferedStreamReader, and StringBuffer, I can successfully read the file into a JOptionPane in my applet.
The problem comes when I try to write data TO this file. I know the file exists because the applet can read it. I've set the permissions on the file to 666. I've got all of the appropriate syntax within a try statment that catches an IOException. I also have JOptionPanes all over the place to let me know where the program is. I've tried different combinations of output streams like BufferedWriter, BufferedOutputStream, StringWriter, but the file does not get updated. When the applet runs, it does not throw any exceptions, not even when I change the URL from "HTTP://www.whatever.com/prefs.txt" to "HTTP:/www.whatever.com/prefs.txt" (only one slash on HTTP, shouldn't I get a MalformedURLException?)
I apologize for all the background, but I thought you might need it. The bottom line is:
1) Can an applet write to a file on a remote server (not local hard disk)?
2) If so, what (if any) caveats are there?
3) Is there a way to check for file existence or be able to create a new file?
4) I'm using the HTTP protocol - is there some restriction that prevents an applet from writing to a file using that protocol? If so, is there a workaround?
5) Assuming that creating/writing a file using the method I've described is possible, what would be the appropriate output streams to use? (Currently, I'm using OutputStreamWriter with BufferedWriter).
I've been struggling with this for a while. Any help/suggestions would be appreciated.
Thanks
P.S. I also posted this message on the Applet development forum, but I've received no response as of yet.Http servers support PUT as a mechanism to upload data to a specified URL. Get on the other hand which is what most people are familiar with is how you retrieve that data. The basic URLConnection is an abstraction of the Http connection which can be used for GET and POST operations by default based on doInput(true|false).. If you which to use any of the http methods other than GET|POST you will have to cast the URLConnection to HttpURLConnection so you can gain access to the specific Http functionaility that could not be abstracted.
Since you are using a hosting service the chances are that you won't be able to use HTTP PUT on their server. Most servers do not support HTTP PUT without configuring them todo so. Now Apache allows localized config through the .htacess file. It might be possible (keep in mind I am not an apache expert) to configure a particular directory to allow HTTP PUT using this .htacess file it may not be possible. You will have to consult the Apache web server documentation for that answer.
But regardless you can use the HttpURLConnection and the PUT method to send data from your applet to the server. In fact that is the preferred way to do this. If you can not configure your web server to support that method then you will have to develop a Servlet to do it. A servlet has several methods such as doGet(), doPost(), and doPut(). You would override the doPut() method get the URI path create a file and a FileOutputStream to that file, get from the request the inputstream, possibly skip the http headers, and then write byte for byte the incoming data to your OutputStream until you reach the end at which point you would close the OutputStream and send an Http Response of some sort. Typically in HTTP it would be 200 OK plus some web content. You content can be empty so long as your applet recognizes that is what it should expect...
And away you go... -
Using HS.Exp function to write data to a Consolidated Account
Hi,
Just wanted to know whether i can use the HS.Exp function to write data to a consolidated account?
ThanksHi Mau,
In order to write data to a consolidated account, you can use HS.Exp function in rules which puts data into a combination of Account, ICP, and Custom1...4 members. The syntax is: HS.Exp "DestPOV = Expression"
You might find useful the HS.Con function which puts data into the [Proportion] and [Elimination] Value dimension members and can also be used in Consolidation rules. The syntax is: Call HS.Con ("V#[Elimination]",-1*dPCon,"")
Regards,
Thanasis -
Trying to write data to a text file using java.io.File
I am trying to create a text file and write data to it by using java.io.File and . I am using JDeveloper 10.1.3.2.0. When I try run the program I get a java.lang.NullPointerException error. Here is the snippet of code that I believe is calling the class that's causing the problem:
String fpath = "/test.html";
FileOutputStream out = new FileOutputStream(fpath);
PrintStream pout = new PrintStream(out);
Do I need to add additional locations for source files or am I doing something wrong? Any suggestions would be appreciated.
Thank you.Hi dhartle,
May be that can help:
* Class assuming handling logs and connections to the Oracle database
* @author Fabre tristan
* @version 1.0 03/12/07
public class Log {
private String fileName;
* Constructor for the log
public Log(String name) {
fileName = name;
* Write a new line into a log from the line passed as parameter and the system date
* @param line The line to write into the log
public void lineWriter(String line) {
try {
FileWriter f = new FileWriter(fileName, true);
BufferedWriter bf = new BufferedWriter(f);
Calendar c = Calendar.getInstance();
Date now = c.getTime();
String dateLog =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
Locale.FRANCE).format(now);
bf.write("[" + dateLog + "] :" + line);
bf.newLine();
bf.close();
} catch (IOException e) {
System.out.println(e.getMessage());
* Write a new line into a log from the line passed as parameter,
* an header and the system date
* @param header The header to write into the log
* @param info The line to write into the log
public void lineWriter(String header, String info) {
lineWriter(header + " > " + info);
* Write a new long number as line into a log from the line
* passed as parameter, an header and the system date
* @param header The header to write into the log
* @param info The line to write into the log
public void lineWriter(String header, Long info) {
lineWriter(header + " > " + info);
* Enable to create folders needed to correspond with the path proposed
* @param location The path into which writing the log
* @param name The name for the new log
* @return Log Return a new log corresponding to the proposed location
public static Log myLogCreation(String location, String name) {
boolean exists = (new File(location)).exists();
if (!exists) {
(new File(location)).mkdirs();
Log myLog = new Log(location + name);
return myLog;
* Enable to create the connection to the DB
* @return Connection Return a new connection to the Oracle database
public static Connection oracleConnectionCreation() throws Exception {
// Register the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
//connecting to the DB
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@myComputerIP:1521:myDB","user", "password");
return conn;
* This main is used for testing purposes
public static void main(String[] args) {
Log myLog =
Log.myLogCreation("c:/Migration Logs/", "Test_LinksToMethod.log");
String directory = "E:\\Blob\\Enalapril_LC-MS%MS_MS%MS_Solid Phase Extraction_Plasma_Enalaprilat_ERROR_BLOB_test";
myLog.lineWriter(directory);
System.out.println(directory);
[pre]
This class contained some other functions i've deleted, but i think it still works.
That enables to create a log (.txt file) that you can fill line by line.
Each line start by the current system date. This class was used in swing application, but could work in a web app.
Regards,
Tif -
Exporting data from text file to a table using utl_file
Dear all,
I have a text file as below and i have a table having 12 columns. Now i need to insert this text file into the table story_books.
CREATE TABLE story_books
book_id NUMBER,
Category VARCHAR2(100 BYTE),
Book_type VARCHAR2(100 BYTE),
Name VARCHAR2(700 BYTE),
Location VARCHAR2(700 BYTE),
Ownership_code VARCHAR2(700 BYTE),
Author VARCHAR2(700 BYTE),
Less_Sel_fact VARCHAR2(700 BYTE),
Reason VARCHAR2(700 BYTE),
Buying VARCHAR2(700 BYTE),
Suspected Book VARCHAR2(700 BYTE),
Conditions VARCHAR2(700 BYTE)
-------------------------text file---------------
Books Out Table: Books
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Buying (if applicable):
Not Applicable
Suspected Book:
Unknown
Conditions to increace sales:
Advertisement in all areas
i was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Thanks in advance.Dear all,
I have a text file as below and i have a table having 12 columns. Now i need to insert this text file into the table story_books.
CREATE TABLE story_books
book_id NUMBER,
Category VARCHAR2(100 BYTE),
Book_type VARCHAR2(100 BYTE),
Name VARCHAR2(700 BYTE),
Location VARCHAR2(700 BYTE),
Ownership_code VARCHAR2(700 BYTE),
Author VARCHAR2(700 BYTE),
Less_Sel_fact VARCHAR2(700 BYTE),
Reason VARCHAR2(700 BYTE),
Buying VARCHAR2(700 BYTE),
Suspected Book VARCHAR2(700 BYTE),
Conditions VARCHAR2(700 BYTE)
-------------------------text file---------------
Books Out Table: Books
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Buying (if applicable):
Not Applicable
Suspected Book:
Unknown
Conditions to increace sales:
Advertisement in all areas
i was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Thanks in advance.
Maybe you are looking for
-
Hi, I have developed a ALV report . I also want to take the print out of this report. How can i do this.
-
Can't scan to or from Mac to C4780
I was having problems with fuzzy or no picture when scanning. I used to use a HP Scan option on my Mac. But I upgraded the drivers for OS X 10.9.3. I no longer have the full disk version. HELP! Need to scan some pics and documents to send off. Thank
-
Okay you guys, i'm in need of a little help here. I just went through the system recovery discs. It says it's done, and to its credit, it does look like it's completely restored windows 7. However now, when i attempt to access the internet, it freaks
-
I'd like to project what's on my Mac Mini (with Samsung monitor) to my Samsung TV (standard definition) via my WIFI. What HDM1 dongle should I buy?
-
Why can't I open my BlackBerry Messenger?
I'm having this problem with my BlackBerry. I don't know why I can't open my BlackBerry Messenger. I've tried to plugged out the battery and put it back in but still, I can't open my BlackBerry Messenger. So I did it repeatedly but I can't still open