How to pump data to txt file using Oracle datapump? - oracle

all hope for you.
I need to export a huge table (900 fields, 1 000 000 strings) in to txt ansi file.
UTL_FILE takes a lot of time. It is not suitable in this task.
I'am trying to use Oracle Datapump, but i can't receive txt file with ansi symbols in it (only 2TTЁ©QRўҐEJЉ•).
Can anybody advice me anything.
Thank you in advance.

Oracle Data Pump can only export in its proprietary binary format.
If you want to export data to text you have only a few options:
PL/SQL or Java (stored) procedure which writes a file using UTL_FILE or the Java equivalent api.
A program running outside the database that writes to a file. Use whichever language you're comfortable with.
Pro*C might be a good choice as it is apparently much faster than the UTL_FILE approach, see http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:459020243348
Use a special SQL script and run it in SQL*Plus using spooling. This is the "SQL Unloader" approach, see http://www.orafaq.com/wiki/SQL*Loader_FAQ#Is_there_a_SQL.2AUnloader_to_download_data_to_a_flat_file.3F
Googling "SQL Unloader" comes up with a few ready-made solutions that you might be able to use directly or modify for your needs.

Related

From selected data into PDF using RDF file

I am currently trying to convert a simple table into a PDF file using an existing .rdf file.
My first approach was to look for a new program that can do so because I want to replace the current 'Oracle Reports' program.
Is there any other program that would support converting SQL data into an PDF using an .rdf File?
I tried writing a Python 3 script to do just that, but I would not know where to start.
Oracle APEX 21.2 (latest at the current time) has a package named APEX_DATA_EXPORT that can take a SELECT statement and export it into various formats, one of them being PDF. The example in the documentation shows how to generate a PDF from a simple query. After calling apex_data_export.export, you can use the BLOB that is returned by the function and do whatever you need with the PDF.
There are not very many options for styling and formatting the table, but Oracle does plan on adding additional printing capabilities for PDFs in the future.

How to update data in CSV files in oracle stored procedure

Create a stored procedure that will read the .csv file from oracle server path using read file operation, query the data in some X table and write the output in .csv file.
here after read .csv file, compare .csv file data with table data and need to update few columns in .csv file.
Oracle works best with data in the database. UPDATE is one of the most frequently used commands.
But, modifying a file which resides in some directory seems to be somewhat out of scope. There are other programming languages you should use, I believe. However, if a hammer is the only tool you have, every problem looks like a nail.
I can think of two options.
One is to load file into the database. Use SQL*Loader to do that if file resides on your PC, or - if you have access to the database server and DBA granted you read/write privileges on a directory (an Oracle object which points to a filesystem directory) - use it as an external table. Once you load data, modify it and export it back (i.e. create a new CSV file) using spool.
Another option is to use UTL_FILE package. It also requires access to the database server's directory. Using the A(ppend) option, you can add rows to the original file, but I don't think that you can edit it so this option - at the end - finishes like the previous one - with creating a new file (but this time using UTL_FILE).
Conclusion? Don't use a database management system to modify files. Use another tool.

Best method to compare data between 2 different databases on separate servers

We are migrating data from DB2 database to Hadoop. The migration really is running select * from table1 on DB2, exporting it to a delimited file, taking that file and putting it Hadoop. DB2 and Hadoop reside on different servers, different network. We need to run some validation steps to make sure that the data that is extracted from DB2 has entirely been imported to Hadoop. So, just running select count(1) from table1 on both the systems would not help since we could have cases where some column values could not be imported due to specific character issue(e.x. newline etc).
What would be the best method to programmatically test that data is identical on both the systems?
P.S: Both Hadoop and DB2 are running on RHEL, so if any Linux specific tools that would be helpful in this process can be included.
Not sure if this is the "best" way, but my approach would be:
As as one of the previous posters has suggested, export data from Hadoop to a delimited file and run a diff against the DB2 import files. This is probably the easiest method.
Write a simple utility which connects to both databases simultaneously, fetches data from two tables to compare, and compares the result set. Having Googled a bit, seems like there are some utilities out there already - for example http://www.dbsolo.com/datacomp.html.
Hope this helps.

Mass Export of BLOB data to CSV

I am working with an older Oracle database, I don't know which version of oracle, sorry, and I need to do a mass export of 200,000+ files worth of HTML data stored in BLOBs. I have downloaded and used both Toad and SQLDeveloper (Oracle's own DB GUI tool) and at best I am able to properly extract the HTML for a single row at a time.
Is there a way (query, tool, other GUI, etc...) that I can reliably do a mass export of all the BLOB data on this table to a CSV format?
Thank You.
You can use utl_file built-in package through this you can write blob data to a file.
Refer here.
I found this tool.
It works incredibly well for extracting content of any type out of any sort of LOB to a file type (HTML in this case). Takes about an hour to do 200,000 records though

Writing to oracle logfile from unix shell script?

I am having a Oracle concurrent program which calls a UNIX shell script which will execute SQL loader program. This is used for inserting flat file from legacy to Oracle Base tables.
My question here is,
How do I capture my custom messages, validation error messages etc in the Oracle log file of the concurrent program.
All help in this regards are much appreciated.
It looks like you are trying to launch SQL*Loader from Oracle Apps. The simplest way would be to use the SQL*Loader type of executables, this way you will get the output and log files right in the concurrent requests window.
If you want to write in the log file and the output file from a unix script, you can find them in the FND_CONCURRENT_REQUESTS table (column logfile_name and outfile_name). You should get the REQUEST_ID passed as a parameter to your script.
These files should be in $XX_TOP\log and should be called l{REQUEST_ID}.req and o{REQUEST_ID}.out (apps 11.5.10).
How is your concurrent process defined? If it's using the "Host" execution method then the output should go into the concurrent log file. If it's being executed from a stored procedure, I'm not sure where it goes.
Have your script use sqlplus to sign into oracle, and insert/update the information you need.

Resources