DPSP
Contacts About Us


Powered by Dynamic PSP
  1. What is Dynamic PSP?
  2. What are the differences between Oracle PSP and Dynamic PSP?
  3. Why not use JSP?
  4. Why Oracle still supports PL/SQL when they integrated Java into Oracle RDBMS?
  5. How To Secure Dynamic PSP Development Interface?
  6. How to enable native PL/SQL compilation in 9i Release 2 on Windows?
  7. I am unable to login into Unit Commander using default account.
  8. What is WebDAV?
  9. How to avoid redirection from index.html to DPSP unit?
  10. Java class to convert xls to csv or from MS Excel to CSV file into PL/SQL and upload data from .xls file to Oracle
  11. Java class to convert from DBF (DB2) to CSV file within Oracle PL/SQL

Java class to convert from DBF (DB2) to CSV file within Oracle PL/SQL

* nn$dbf2csv.dbf2csv
*
* Java Utility class for convert DBF file to CSV file
* and upload data from .csv file to Oracle Database
* Copyright(c) 2000-2007 by Andrew Toropov All rights reserved.
* Written by Andrew A. Toropov
*

1. How to Install
>loadjava -v -u user/pass@[TNSNAME] -r dbf2csv.jar
>sqlplus user/pass@[TNSNAME] @dbf2csv.sql

2. How to Run
>sqlplus user/pass@[TNSNAME]
sql>
set serverout on
declare
Path varchar2(1000) := '/temp/'; -- directory with perms
DFBFile varchar2(1000) := 'DFBFile.dbf';
CSVFile varchar2(1000) := 'CSVFile.csv';
Fine varchar2(1000);
begin
Fine :=
nn$dbf2csv.dbf2csv(Path||DFBFile, Path||CSVFile, ';');
dbms_output.put_line(substr(Fine,1,255));
end;
/

File -/temp/'CSVFile.csv will be created
Warning! Grant Oracle Java permissions to USER.
> sqlplus "sys/[password]@[TNSNAME] as sysdba"
sql>
begin
dbms_java.grant_permission('USER',
'SYS:java.io.FilePermission',
'/temp/-',
'read,write,delete');
end;
CREATE OR REPLACE DIRECTORY temp AS '/temp/';
GRANT READ ON DIRECTORY temp TO user;
GRANT WRITE ON DIRECTORY temp TO user;
GRANT DELETE ON DIRECTORY temp TO user;
/

3. Now you can upload data from .csv file to an Oracle Database

>sqlplus user/pass@[TNSNAME]
sql>
declare
Path varchar2(1000) := '/temp/'; -- directory with perms
DFBFile varchar2(1000) := 'DFBFile.dbf';
CSVFile varchar2(1000) := 'CSVFile.csv';
Fine varchar2(1000);
begin
Fine :=
nn$dbf2csv.dbf2csv(Path||DFBFile, Path||CSVFile, ';');
execute immediate Fine;
end;
4. Now you can fetch data from Oracle external table created based on Excel file

>sqlplus user/pass@[TNSNAME]
sql> select * from NNDBF$DFBFile;


Back to the top of page
email us
Copyright © 2000-2017 by HitMedia LLC. All Rights Reserved.