How to get the data from a file and insert into a table
Good morning,
NEED TO READ THIS FILE sui_facturacion_alcantarillado_15085_2011_01_76845_00A.csv containing the following information
NUID,NUMERO_DE_CUENTA_CONTRATO,CÓDIGO_DANE_DEPARTAMENTO,CÓDIGO_DANE_MUNICIPIO,ZONA_IGAC,SECTOR_IGAC,MANZANA_O_VEREDA_IGAC,NÚMERO_DEL_PREDIO_IGAC,CONDICION_DE_PROPIEDAD_DEL_PREDIO_IGAC,DIRECCIÓN_DEL_PREDIO,NÚMERO_DE_FACTURA,FECHA_DE_EXPEDICIÓN_DE_LA_FACTURA,FECHA_DE_INICIO_DEL_PERÍODO_DE_FACTURACIÓN,DIAS_FACTURADOS,CÓDIGO_CLASE_DE_USO,UNIDADES_MULTIUSUARIO_RESIDENCIAL,UNIDADES_MULTIUSUARIO_NO_RESIDENCIAL,HOGAR_COMUNITARIO_O_SUSTITUTO,USUARIO_FACTURADO_CON_AFORO,USUARIO_CUENTA_CON_CARACTERIZACIÓN,CARGO_FIJO,CARGO_POR_VERTIMIENTO_BASICO,CARGO_POR_VERTIMIENTO_COMPLEMENTARIO,CARGO_POR_VERTIMIENTOSUNTUARIO,CMT,VERTIMIENTO_DEL_PERIOD_EN_METROS_CUBICOS,VALOR_FACTURADO_POR_VERTIDO,VALOR_DEL_SUBSIDIO,VALOR_DE_LA_CONTRIBUCIÓN,FACTOR_DE_SUBSIDIO_O_CONTRIBUCIÓN_CARGO_FIJO,FACTOR_DE_SUBSIDIO_O_CONTRIBUCIÓN_VERTIMIENTO,CARGOS_POR_CONEXIÓN,PAGO_ANTICIPADO_DEL_SERVICIO,DÍAS_DE_MORA,VALOR_DE_MORA,INTERESES_POR_MORA,OTROS_COBROS,CAUSAL_DE_REFACTURACIÓN,NUMERO_DE_LA_FACTURA_OBJETO_DE_REFACTURACIÓN,VALOR_TOTAL_FACTURADO,PAGOS_DEL_CLIENTE_DURANTE_EL_PERÍODO_FACTURADO
242602,242602,76,845,99,99,9999,9999,999,CLL 5 CRA 7 PEATONAL,24911920,12-01-2011,01-12-2010,30,01,,,0,0,0,1,0000000000.00,0000000000.00,0000000000.00,0000000000.00,0000000005,0000002200.00,0000000000,0000000000,0.000,0.000,0000000000.00,0000000000.00,0,0000000000.00,0000000000.00,0000000000.00,0,0,0000002201.00,0000000000.00
242604,242604,76,845,99,99,9999,9999,999,CRA 4 # 6 - 13,24911846,12-01-2011,01-12-2010,30,01,,,0,0,0,1,0000000000.00,0000000000.00,0000000000.00,0000000000.00,0000000013,0000002200.00,0000000000,0000000000,0.000,0.000,0000000000.00,0000000000.00,0,0000000000.00,0000000000.00,0000000000.00,0,0,0000002201.00,0000004411.00
242605,242605,76,845,99,99,9999,9999,999,CRA 2 CLLES 3 Y 4,24911509,12-01-2011,01-12-2010,30,01,,,0,0,0,1,0000000000.00,0000000000.00,0000000000.00,0000000000.00,0000000004,0000002200.00,0000000000,0000000000,0.000,0.000,0000000000.00,0000000000.00,0,0000000000.00,0000000000.00,0000000000.00,0,0,0000002201.00,0000002200.00
this is the function that I have
<<function_test>>
DECLARE
TOTAL_CAR NUMBER;
POS_1 NUMBER:= 0;
POS_2 NUMBER:= 0;
REST NUMBER:= 0;
ACUM NUMBER:= 0;
CADEN VARCHAR2(200);
nom_archivo varchar2(80);
v1 utl_file.file_type;
v2 varchar2(2048);
BEGIN
nom_archivo := 'sui_facturacion_alcantarillado_15085_2011_01_76845_00A.csv';
v1:= utl_file.fopen('PUBLIC_ACCESS',nom_archivo,'R',32767);
utl_file.get_line(v1,v2);
SELECT LENGTH(v2) INTO TOTAL_CAR FROM DUAL;
ACUM:=1;
POS_1:=0;
WHILE ACUM <= 60
LOOP
select instr(v2, ',', 1, ACUM) PRUEBA
INTO POS_2
FROM DUAL;
dbms_output.put_line(' TOTAL POSICION 1--> '|| POS_1);
dbms_output.put_line(' TOTAL POSICION 2--> '|| POS_2);
dbms_output.put_line(' TOTAL ACUMULADO --> '|| ACUM);
REST := (POS_2-POS_1)-1;
SELECT SUBSTR(v2,(POS_1+1),REST) PRUEBA2
INTO CADEN
FROM DUAL;
dbms_output.put_line(' CADENA SELECCIONADA --> '|| CADEN);
ACUM := ACUM + 1;
POS_1:= POS_2;
END LOOP;
utl_file.fclose(v1);
dbms_output.put_line(' -->');
dbms_output.put_line(' TOTAL POSICION 1-->'|| POS_1);
dbms_output.put_line(' TOTAL POSICION 2-->'|| POS_2);
dbms_output.put_line(' TOTAL ACUMULADO -->'|| ACUM);
dbms_output.put_line(' TOTAL DE CARACTERES -->'|| TOTAL_CAR);
dbms_output.put_line(' ');
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('NO SE ENCONTRARON MAS CARACTERES');
WHEN OTHERS THEN
dbms_output.put_line('OTRO TIPO DE ERROR ');
dbms_output.put_line('CODIGO ERROR '|| SQLCODE ||' '||SQLERRM);
END;
Which must be separated by a comma and enter a table I have the following procedure in which only brings me the first line, which need not
The current role I have just read and extract data from the row number 1, I do not need information.
I need information for rows 2,3,4. In each row there are 41 fields, which I enter in a table called Dato_archivos.
how to perform this function? ...
I appreciate the cooperation and explanation ...
GOOD DAY ...
REYNEL SALAZAR MARTINEZ
COLOMBIA ...
When you get an error with external tables (or sql*loader) look in the same folder as the data file and you should get a .log file and maybe a .bad file too.
The log file should indicate the nature of the error it has trying to load the data.
I've just copied your sample data from your first post to a file on my server and tried it to find that you are not specifying the required format for your dates. The below shows it now working...
CREATE TABLE tabla_prueba
(NUID NUMBER,
NUM_CUENTA_CONTRATO NUMBER,
COD_DANE_DD NUMBER,
COD_DANE_MM NUMBER,
ZONA_IGAC NUMBER,
SECTOR_IGAC NUMBER,
MANZANA_VEREDA_IGAC NUMBER,
NUM_PREDIO_IGAC NUMBER,
CONDICION_PREDIO_IGAC NUMBER,
DIRECCION_PREDIO_IGAC VARCHAR2(80),
NUM_FACTURA NUMBER,
FECHA_EXPED_FACTURA DATE,
FECHA_INI_PERIODO_FACTURACION DATE,
DIAS_FACTURADOS NUMBER,
COD_CLASE_USO NUMBER,
UNI_MULTIUSUARIO_RESIDENCIAL NUMBER,
UNI_MULTIUSUARIO_NORESIDENCIAL NUMBER,
HOGAR_COMUNITARIO NUMBER,
USUARIO_FACTURADO_AFORO NUMBER,
USUARIO_CON_CARACTERIZACION NUMBER,
CARGO_FIJO NUMBER,
CARGO_VERTIMENTO_BAS NUMBER,
CARGO_VERTIMENTO_COMP NUMBER,
CARGO_VERTIMENTO_SUNT NUMBER,
CMT NUMBER,
VLR_FACTURADO_VERTIDO NUMBER,
VLR_SUBSIDIO NUMBER,
VLR_CONTRIBUCCION NUMBER,
FACTOR_SUBS_CONTR_CARGO_FIJO NUMBER,
FACTOR_SUBS_CONTR_VERTIMENTO NUMBER,
CARGO_CONEXION NUMBER,
PAGO_ANTICIPADO_SERVICIO NUMBER,
DIAS_MORA NUMBER,
VLR_MORA NUMBER,
INTERES_MORA NUMBER,
OTROS_COBROS NUMBER,
CAUSAL_REFACTURACION NUMBER,
NUM_FACTURA_OBJ_REFACTURACION NUMBER,
VLR_TOTAL_FACTURADO NUMBER,
PAGOS_CLIENTE_DURANTE_PERIODO NUMBER
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY TEST_DIR
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
SKIP 1
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
(NUID,
NUM_CUENTA_CONTRATO,
COD_DANE_DD,
COD_DANE_MM,
ZONA_IGAC,
SECTOR_IGAC,
MANZANA_VEREDA_IGAC,
NUM_PREDIO_IGAC,
CONDICION_PREDIO_IGAC,
DIRECCION_PREDIO_IGAC,
NUM_FACTURA,
FECHA_EXPED_FACTURA CHAR DATE_FORMAT DATE MASK "DD-MM-YYYY",
FECHA_INI_PERIODO_FACTURACION CHAR DATE_FORMAT DATE MASK "DD-MM-YYYY",
DIAS_FACTURADOS,
COD_CLASE_USO,
UNI_MULTIUSUARIO_RESIDENCIAL ,
UNI_MULTIUSUARIO_NORESIDENCIAL,
HOGAR_COMUNITARIO ,
USUARIO_FACTURADO_AFORO ,
USUARIO_CON_CARACTERIZACION ,
CARGO_FIJO ,
CARGO_VERTIMENTO_BAS ,
CARGO_VERTIMENTO_COMP,
CARGO_VERTIMENTO_SUNT,
CMT,
VLR_FACTURADO_VERTIDO,
VLR_SUBSIDIO ,
VLR_CONTRIBUCCION ,
FACTOR_SUBS_CONTR_CARGO_FIJO ,
FACTOR_SUBS_CONTR_VERTIMENTO ,
CARGO_CONEXION ,
PAGO_ANTICIPADO_SERVICIO ,
DIAS_MORA ,
VLR_MORA ,
INTERES_MORA ,
OTROS_COBROS ,
CAUSAL_REFACTURACION ,
NUM_FACTURA_OBJ_REFACTURACION,
VLR_TOTAL_FACTURADO,
PAGOS_CLIENTE_DURANTE_PERIODO
LOCATION ('test.csv')
SQL> select * from tabla_prueba;
NUID NUM_CUENTA_CONTRATO COD_DANE_DD COD_DANE_MM ZONA_IGAC SECTOR_IGAC MANZANA_VEREDA_IGAC NUM_PREDIO_IGAC CONDICION_PREDIO_IGAC DIRECCION_PREDIO_IGAC NUM_FACTURA FECHA_EXPE FECHA_INI_
DIAS_FACTURADOS COD_CLASE_USO UNI_MULTIUSUARIO_RESIDENCIAL UNI_MULTIUSUARIO_NORESIDENCIAL HOGAR_COMUNITARIO USUARIO_FACTURADO_AFORO USUARIO_CON_CARACTERIZACION CARGO_FIJO CARGO_VERTIMENTO_BAS CARGO_VERTIMENTO_COMP CARGO_VERTIMENTO_SUNT CMT
VLR_FACTURADO_VERTIDO VLR_SUBSIDIO VLR_CONTRIBUCCION FACTOR_SUBS_CONTR_CARGO_FIJO FACTOR_SUBS_CONTR_VERTIMENTO CARGO_CONEXION PAGO_ANTICIPADO_SERVICIO DIAS_MORA VLR_MORA INTERES_MORA OTROS_COBROS CAUSAL_REFACTURACION NUM_FACTURA_OBJ_REFACTURACION
VLR_TOTAL_FACTURADO PAGOS_CLIENTE_DURANTE_PERIODO
242602 242602 76 845 99 99 9999 9999 999 CLL 5 CRA 7 PEATONAL 24911920 12-01-2011 01-12-2010
30 1 0 0 0 1 0 0 0 0
5 2200 0 0 0 0 0 0 0 0 0 0 0
0 2201
242604 242604 76 845 99 99 9999 9999 999 CRA 4 # 6 - 13 24911846 12-01-2011 01-12-2010
30 1 0 0 0 1 0 0 0 0
13 2200 0 0 0 0 0 0 0 0 0 0 0
0 2201
242605 242605 76 845 99 99 9999 9999 999 CRA 2 CLLES 3 Y 4 24911509 12-01-2011 01-12-2010
30 1 0 0 0 1 0 0 0 0
4 2200 0 0 0 0 0 0 0 0 0 0 0
0 2201
SQL>
{code}
Similar Messages
-
How to read the data from XML file and insert into oracle DB
Hi All,
I have below require ment.
I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
Many Thanks.Sounds a lot like this question, only with less details.
how to read data from XML variable and insert into table variable
We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us. Plenty of examples abound on the forums that cover the topics you seek as well. -
How to read the data from excel file and store into the table?
Hi All,
I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
All the excel fields and my table columns are same.
Can you share with me how can acheive this using LOB's?
ThanksHi OraSuirya,
you can try with external tables .
syntax as follows
create table ext_table_csv (
i Number,
n Varchar2(20),
m Varchar2(20)
organization external (
type oracle_loader
default directory ext_dir
access parameters (
records delimited by newline
fields terminated by ','
missing field values are null
location ('file.csv')
reject limit unlimited;
For this you need to create directory
Directory Creation syntax:
create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
grant read, write on directory ext_dir to <User>;
please paste the excel file in the particular directory .
I hope this will help you.
Please correct me if I am wrong anywhere .
Thanks,
Tippu. -
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 -
Get the filename from a directory and insert into a table
Hi,
I have a requirement, i need to read the file name from a Linux directory and get that file name into a variable,
After that i need to insert that file name into a table.
EX: let their is a file1.txt in abc directory , and i read that "file name" into v_file_name variable and i am going to insert that file name into a table.You should have something common in all your file name that can be used to distinguish between them.
Ex: Suppose file names are like FILENAME_PKG1,FILENAME_PKG2,FILENAME_PKG3 then it will be easier to develop the logic inside ODI so that FILENAME_PKG1 can be processed by package1 ,FILENAME_PKG2 can be processed by package2 ,FILENAME_PKG3 can be processed by package3.
Hope you got, what i want to say.
Thanks. -
How to read the data from Excel file and Store in XML file using java
Hi All,
I got a problem with Excel file.
My problem is how to read the data from Excel file and Store in XML file using java excel api.
For getting the data from Excel file what are all the steps i need to follow to get the correct result.
Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
Thanks & Regards,
Sreenu,
[email protected],
india,If you want someone to do your work, please have the courtesy to provide payment.
http://www.rentacoder.com -
Hi, extract data from xml file and insert into another exiting xml file
i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
1st xml file which has two lines(text1.xml)
<?xml version="1.0" encoding="iso-8859-1"?>
<xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
<xs:Person>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
Regards,
bubblyJadz_Core wrote:
RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort. -
Extract data from xml file and insert into another exiting xml fil
hello,
i am searching extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
Regards,
ZhuozhiIf the files are small, you can load the target file in a DOM document, insert the data from the source file and persist the DOM.
If the files are large, you probably want to use a StAX or SAX. -
Pool data from text file and insert into database
Can anyone tell me how to pool data from a text file and insert into database?
let's say my text file is in this format
123456 Peter 22
234567 Nicholas 24
345678 Jane 20
Then I need to insert the all the value for this three column into a table which has the three column name ID, Name, Age
Anyone knows? I need to do this urgently...Thank in advanced1. Use BufferedReader and read the file line by line.
2. Loop thru the file and do the following steps with in this loop.
3. Use StringTokenizer to seperate each line into three values (columns).
4. Now create a insert statement with these values and add the statement to the batch (using addBatch() method of PreparedStatement or Statement).
5. Finally (after exiting the loop), execute these batch of statements (using ps.executeBatch()).
Sudha -
How to get the data from multiple nodes to one table
Hi All,
How to get the data from multiple nodes to one table.examples nodes are like A B C D E relation also maintained
Regards,
IndraHI Indra,
From Node A, get the values of the attributes as
lo_NodeA->GET_STATIC_ATTRIBUTES( IMPORTING STATIC_ATTRIBUTES = ls_attributesA ).
Similarily get all the node values from B, C, D and E.
Finally append all your ls records to the table.
Hope you are clear.
BR,
RAM. -
How to get the data from pcl2 cluster for TCRT table.
Hi frndz,
How to get the data from pcl2 cluster for tcrt table for us payroll.
Thanks in advance.
Harisumanth.ChPL take a look at the sample Program EXAMPLE_PNP_GET_PAYROLL in your system. There are numerous other ways to read payroll results.. Pl use the search forum option & you sure will get a lot of hits..
~Suresh -
How to get the data from Pooled Table T157E.
Hi Experts,
How to get the data from Pooled Table T157E.
Any help.
Thanks in Advance,
Ur's Harsha.create some internal table similar to T157E and pass all data as per SPRAS.
After that use internal table in your program as per the requirement.
Regds,
Anil -
How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.
If the data is on a remote server (for example, PHP running on a web server, talking to a MySQL server) then you do this in an AIR application the same way you would do it with any Flex application (or ajax application, if you're building your AIR app in HTML/JS).
That's a broad answer, but in fact there are lots of ways to communicate between Flex and PHP. The most common and best in most cases is to use AMFPHP (http://amfphp.org/) or the new ZEND AMF support in the Zend Framework.
This page is a good starting point for learning about Flex and PHP communication:
http://www.adobe.com/devnet/flex/flex_php.html
Also, in Flash Builder 4 they've added a lot of remote-data-connection functionality, including a lot that's designed for PHP. Take a look at the Flash Builder 4 public beta for more on that: http://labs.adobe.com/technologies/flashbuilder4/ -
How to Load the data from excel file(Extension is .CSV) into the temp.table
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinHello Sachin,
You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
Instead of copy values into forms you can save them in your temporary table.
Kind regards,
Alex
If someone's helpful or correct please mark it accordingly. -
How to load the data from .csv file to oracle table???
Hi,
I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
Thanks in advance981145 wrote:
Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
the command is
sqlldrType it and see if you have it installed.
Have a look also at the FAQ link posted by Marwin.
There are plenty of examples also on the web.
Regards.
Al
Maybe you are looking for
-
Unable to Reinstall iTunes - error message: "Apple Application Support was not found"
When attempting to update my iPhone today, my iTunes would not open. I followed the instructions to completely uninstall iTunes, Apple Software Update, Apple Mobile Device Support, Bonjour, and Apple Applications Support. I then attempted to reinst
-
Iphone 6 and the lies Verizon keeps pushing
Order 2 iphone 6's on 10/08/2014 with a 10/24/2014 delivery date. Called twice that day because I hadn't had notification and was told that it shipped and was on it's way....lies. Called later that night talked to a very good rep and said, they wer
-
How to change the country code for Wireless channel usage
My MacBook country code is set by Japan. In this case, I can use only 5.15~5.25 channels from ch#36 to ch48 at 5GHz Band. I'd like use the other channels..by other country code. How can I change the Wireless card country code?
-
When I buy a song that has the ringtone icon it goes away after I buy it
When I go to my music the icon is gone and I can't create ringtones. How to I get it back?
-
Memory Management - Why not automatic?
I just upgraded from my old 3GS to a iPhone 5 32GB. Really love the new hardware and look, was a worth while upgrade. Within the first two days, I was really disapointed by the battery life I was getting. Even in standby (overnight, while sleeping