darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
1.03k stars 342 forks source link

Error VIEW_AS_TABLE function #56

Closed JuanMorenoDeveloper closed 10 years ago

JuanMorenoDeveloper commented 10 years ago

Greetings

I need help, i have the next error:

DBD::Oracle::st execute failed: ORA-01861: literal does not match format string (DBD ERROR: error possibly near <_> indicator at char 4040 in 'SELECT "ELEMENTO_ID" FROM TABLE_INFO a) [for Statement "SELECT "ELEMENTO_ID" FROM TABLEINFO a"] at /usr/local/share/perl/5.14.2/Ora2Pg.pm line 6493. FATAL: ORA-01861: literal does not match format string (DBD ERROR: error possibly near <> indicator at char 4040 in 'SELECT "ELEMENTO_ID" FROM TABLE_INFO a) Aborting export...

The query works in sqlplus, but not in Ora2Pg.

My configuration file have: Users and paswords and... TYPE INSERT ALLOW TABLE_INFO VIEW_AS_TABLE TABLE_INFO

My version perl is 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi My oracle client is oracle-instantclient11.2-basiclite, oracle-instantclient11.2-devel, oracle-instantclient11.2-sqlplus
My modules are DBD-Oracle-1.70, DBD-Pg-3.1.1 and IO-Compress-2.064 My Machine is Linux server 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux My database is: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit I don't understand the error, makes no sense, other views are imported successfully, Please, help me

darold commented 10 years ago

Hi,

What is the definition of view TABLE_INFO ? And what is the value of NLS_LANG in the ora2pg.conf ?

JuanMorenoDeveloper commented 10 years ago

Hi, The definition is: CREATE TABLE table_info ( identificante bigint, elemento_id bigint, concepto_sct_id bigint, elemento_sct_id bigint, kit_router varchar(23), mantenimiento varchar(50), meses_contratacion varchar(50), suministrado_por varchar(40), cliente_id bigint, razon_social varchar(150), rif varchar(30), tipo_cliente varchar(4), region varchar(25), num_contrato varchar(50), contrato_sip_viejo varchar(15), fecha_inicio varchar(10), fecha_firma varchar(10), factibilidad varchar(40), proyecto varchar(40), tipo char(8), acceso_orig_id bigint, nombre_factura_orig varchar(20), ciudad_orig varchar(60), sector_orig varchar(60), pais_orig varchar(100), acceso_dest_id bigint, nombre_factura_dest varchar(20), ciudad_dest varchar(60), sector_dest varchar(60), pais_dest varchar(100), tarifa double precision, descuento char(2), monto bigint, moneda char(4), nodo_origen varchar(150), nodo_destino varchar(150), ruta varchar(150), primera_factura timestamp, fecha_operatividad varchar(10), fecha_inicio_factura varchar(10), entregado_a_sucuenta varchar(10), cuenta_pagadora bigint, ciclo varchar(40), cuenta_de_uso bigint, lider_acceso varchar(50), gerente varchar(50), ejecutivo varchar(50), status bigint, status_descripcion varchar(100) ); And my NLS is NLS_LANG AMERICAN_AMERICA.UTF8

darold commented 10 years ago

Does TABLE_INFO is a view or a real table ? If this is a view, please comment VIEW_AS_TABLE TABLE_INFO in you configuration file and use export TYPE VIEW and give me the definition of the view.

JuanMorenoDeveloper commented 10 years ago

Yes is a view, the output file is:

CREATE OR REPLACE VIEW table_info (identificante, elemento_id, concepto_sct_id, elemento_sct_id, kit_router, mantenimiento, me ses_contratacion, suministrado_por, cliente_id, razon_social, rif, tipo_cliente, region, num_contrato, contrato_sip_viejo, fecha_ini cio, fecha_firma, factibilidad, proyecto, tipo, acceso_orig_id, nombre_factura_orig, ciudad_orig, sector_orig, pais_orig, acceso_des t_id, nombre_factura_dest, ciudad_dest, sector_dest, pais_dest, tarifa, descuento, monto, moneda, nodo_origen, nodo_destino, ruta, p rimera_factura, fecha_operatividad, fecha_inicio_factura, entregado_a_sucuenta, cuenta_pagadora, ciclo, cuenta_de_uso, lider_acceso, gerente, ejecutivo, status, status_descripcion) AS (SELECT REC.IDENTIFICANTE, REC.ELEMENTO_ID, REC.CONCEPTO_SCT_ID, REC.ELEMENTO_SCT_ID, (CASE WHEN REC.ELEMENTO_SCT_ID = 766 THEN 'Arrendamiento Kit # 1' WHEN REC.ELEMENTO_SCT_ID = 799 THEN 'Arrendamiento Kit # 1' WHEN REC.ELEMENTO_SCT_ID = 822 THEN 'Arrendamiento Kit # 1' WHEN REC.ELEMENTO_SCT_ID = 806 THEN 'Arrendamiento Kit # 2' WHEN REC.ELEMENTO_SCT_ID = 810 THEN 'Arrendamiento Kit # 2' WHEN REC.ELEMENTO_SCT_ID = 823 THEN 'Arrendamiento Kit # 2' WHEN REC.ELEMENTO_SCT_ID = 767 THEN 'Arrendamiento Kit # 3' WHEN REC.ELEMENTO_SCT_ID = 811 THEN 'Arrendamiento Kit # 3' WHEN REC.ELEMENTO_SCT_ID = 824 THEN 'Arrendamiento Kit # 3' WHEN REC.ELEMENTO_SCT_ID = 807 THEN 'Arrendamiento Kit # 4' WHEN REC.ELEMENTO_SCT_ID = 812 THEN 'Arrendamiento Kit # 4' WHEN REC.ELEMENTO_SCT_ID = 825 THEN 'Arrendamiento Kit # 4' WHEN REC.ELEMENTO_SCT_ID = 768 THEN 'Arrendamiento Kit # 5' WHEN REC.ELEMENTO_SCT_ID = 826 THEN 'Arrendamiento Kit # 5' WHEN REC.ELEMENTO_SCT_ID = 769 THEN 'Arrendamiento Kit # 6' WHEN REC.ELEMENTO_SCT_ID = 827 THEN 'Arrendamiento Kit # 6' WHEN REC.ELEMENTO_SCT_ID = 770 THEN 'Arrendamiento Kit # 7' WHEN REC.ELEMENTO_SCT_ID = 828 THEN 'Arrendamiento Kit # 7' WHEN REC.ELEMENTO_SCT_ID = 771 THEN 'Arrendamiento Kit # 8' WHEN REC.ELEMENTO_SCT_ID = 829 THEN 'Arrendamiento Kit # 8' WHEN REC.ELEMENTO_SCT_ID = 808 THEN 'Arrendamiento Kit # 9' WHEN REC.ELEMENTO_SCT_ID = 830 THEN 'Arrendamiento Kit # 9' WHEN REC.ELEMENTO_SCT_ID = 772 THEN 'Arrendamiento Kit Pers.' WHEN REC.ELEMENTO_SCT_ID = 777 THEN 'Arrendamiento Kit Pers.' WHEN REC.ELEMENTO_SCT_ID = 809 THEN 'Gestion Router' ELSE 'N/A' END ) KIT_ROUTER, MT.VALOR MANTENIMIENTO, ME.VALOR MESES_CONTRATACION, RRU.DUENO SUMINISTRADO_POR, CL.IDCLIENTE CLIENTE_ID, INITCAP (CL.NOMBREADMINISTRATIVO) AS RAZON_SOCIAL, CL.RIF, (CASE WHEN CL.IDTIPOGRUPOCLIENTE=1 THEN 'GGUU' ELSE 2, 'PYME' END) TIPO_CLIENTE, INITCAP (SR.LOCALIDAD) REGION, RC.ETIQUETA NUM_CONTRATO, RC.MIG_CONTRATO_ETIQ CONTRATO_SIP_VIEJO, TO_CHAR (RC.FECHA_INICIO, 'DD/MM/YYYY') FECHA_INICIO, TO_CHAR (RC.FECHA_FIRMA, 'DD/MM/YYYY') FECHA_FIRMA, PF.NOMBRE FACTIBILIDAD, PI.NOMBRE PROYECTO, 'Contrato' TIPO, RA.ACCESO_ID ACCESO_ORIG_ID, INITCAP (LO.NOMBRE_FACTURA) NOMBRE_FACTURA_ORIG, INITCAP (LO.CIUDAD) CIUDAD_ORIG, INITCAP (LO.SECTOR) SECTOR_ORIG, DECODE (LO.ES_INTERNACIONAL, 0, 'Venezuela', INITCAP (PA.NOMBRE_PAIS) ) PAIS_ORIG, RA.ACCESO_ID ACCESO_DEST_ID, NULL NOMBRE_FACTURA_DEST, NULL CIUDAD_DEST, NULL SECTOR_DEST, NULL PAIS_DEST, REC.TARIFA_CONT TARIFA, '--' DESCUENTO, ROUND (( REC.TARIFA_CONT * ( 1

JuanMorenoDeveloper commented 10 years ago

And my configuration file so i have: MODIFY_STRUCT tables_info(elemento_id)

darold commented 10 years ago

Strange but if that is working using SQLplus you may retrieve the value of NLS_LANG and NLS_DATE_FORMAT from the SQLplus client and use them with Ora2Pg. You may also set those parameters in environment using the following commands:

export NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'; export NLS_LANG = "american_america.utf8";

adjust to whatever values you have in SQLplus and then run ora2pg from the same terminal.

I never encountered this error but it seems to be related to the date format and need to be fixed by setting the right value to NLS_DATE_FORMAT.

Let me know what values are working.

JuanMorenoDeveloper commented 10 years ago

Good morning Darold

I config the enviroment variables root@kepler:~# env | grep NLS NLS_LANG=american_america.utf8 NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS

and in sqlplus after the changes the output is SQL> select sysdate from dual;

SYSDATE

2014-04-21 07:51:31 But the error message still going root@kepler:/home/movistar-local# ora2pg -c /etc/ora2pg/ora2pg_dataviews2.conf [========================>] 0/0 tables (100.0%) end of scanning. DBD::Oracle::st execute failed: ORA-01861: literal does not match format string (DBD ERROR: error possibly near <> indicator at char 4040 in 'SELECT "ELEMENTO_ID" FROM TABLE_INFO a) [for Statement "SELECT "ELEMENTO_ID" FROM TABLEINFO a"] at /usr/local/share/perl/5.14.2/Ora2Pg.pm line 6493. FATAL: ORA-01861: literal does not match format string (DBD ERROR: error possibly near <> indicator at char 4040 in 'SELECT "ELEMENTO_ID" FROM TABLE_INFO a) Aborting export...

JuanMorenoDeveloper commented 10 years ago

Solved!, The problem was my database oracle. Thanks!