Code Monkey home page Code Monkey logo

Comments (6)

darold avatar darold commented on June 26, 2024

This is not a misconfiguration or a bug, this is the PostgreSQL representation of boolean in COPY output. You will have t for true and f for false. In INSERT statement you will have 't' and 'f'.

Regards

from ora2pg.

bjornbak avatar bjornbak commented on June 26, 2024

Hi Darold,

Thank you for your answer but we misunderstand each other..

I understand that the t represent a true but I don't understand why ALL the rows get a t while some of them should get a f...

from ora2pg.

darold avatar darold commented on June 26, 2024

OK, sorry for the misunderstanding. If REPLACE_AS_BOOLEAN is a list of table_name:column_name there's no misconfiguration. The only things is that you don't need to add 1:0 to BOOLEAN_VALUES as it is defined per default.

I don't see any bug in the code, what version of Ora2Pg are you using ?

from ora2pg.

bjornbak avatar bjornbak commented on June 26, 2024

I'm using ora2pg-11.4 with an Oracle 10.2g

I'm doing a oracle->file migration and then loading these to postgresql with psql.

Could it make a difference if I copy directly to postgresql?

Here is an example:

Oracle DDL:
CREATE TABLE "TRUNK"."AM"
( "ENHED_ID" NUMBER(10,0) CONSTRAINT "AM_ENHED_ID_C" NOT NULL ENABLE,
"ANTAL" NUMBER(5,0) DEFAULT 0 CONSTRAINT "AM_ANTAL_C" NOT NULL ENABLE,
"ANTALBOOKED" NUMBER(5,0) DEFAULT 0 CONSTRAINT "AM_ANTALBOOKED_C" NOT NULL ENABLE,
"DATO" DATE CONSTRAINT "AM_DATO_C" NOT NULL ENABLE,
"LUKKET" NUMBER(1,0) DEFAULT 0 CONSTRAINT "AM_LUKKET_C" NOT NULL ENABLE,
"BR_MINDAGE" NUMBER(3,0) DEFAULT 1 CONSTRAINT "AM_BR_MINDAGE_C" NOT NULL ENABLE,
"MANUELPRIS" NUMBER(6,2),
"BR_ANKOMSTTILLADT" NUMBER(1,0) DEFAULT 1 CONSTRAINT "AM_BR_ANKOMSTTILLADT_C" NOT NULL ENABLE,
"BR_MAXDAGE" NUMBER(3,0),
"BR_AFREJSETILLADT" NUMBER(1,0) DEFAULT 1 CONSTRAINT "AM_BR_AFREJSETILLADT_C" NOT NULL ENABLE,
CONSTRAINT "AM_PK" PRIMARY KEY ("ENHED_ID", "DATO") ENABLE,
CONSTRAINT "AM_CHK1" CHECK (
antal >= antalbooked
);

Postgresql DDL:
CREATE TABLE am
(
enhed_id integer NOT NULL,
antal integer NOT NULL DEFAULT 0,
antalbooked integer NOT NULL DEFAULT 0,
dato timestamp without time zone NOT NULL,
lukket boolean NOT NULL DEFAULT false,
br_mindage integer NOT NULL DEFAULT 1,
manuelpris real,
br_ankomsttilladt boolean NOT NULL DEFAULT true,
br_maxdage integer,
br_afrejsetilladt boolean NOT NULL DEFAULT true,
CONSTRAINT am_pkey PRIMARY KEY (enhed_id, dato),
CONSTRAINT am_chk1 CHECK (antal >= antalbooked)
)

From ora2pg:

REPLACE_AS_BOOLEAN am:br_ankomsttilladt am:br_afrejsetilladt am:lukket

Data in oracle:

"ENHED_ID" "ANTAL" "ANTALBOOKED" "DATO" "LUKKET" "BR_MINDAGE" "MANUELPRIS" "BR_ANKOMSTTILLADT" "BR_MAXDAGE" "BR_AFREJSETILLADT"
"1032" "10" "3" "01-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "3" "02-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "4" "03-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "1" "04-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "1" "05-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "1" "06-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "0" "07-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "0" "08-JAN-11 00:00" "0" "1" "" "1" "" "1"
"1032" "10" "0" "09-JAN-11 00:00" "0" "1" "" "1" "" "1"

Data in copy:

COPY am (enhed_id,antal,antalbooked,dato,lukket,br_mindage,manuelpris,br_ankomsttilladt,br_maxdage,br_afrejsetilladt) FROM STDIN;
1032 10 3 2011-01-01 00:00:00 t 1 \N t \N t
1032 10 3 2011-01-02 00:00:00 t 1 \N t \N t
1032 10 4 2011-01-03 00:00:00 t 1 \N t \N t
1032 10 1 2011-01-04 00:00:00 t 1 \N t \N t
1032 10 1 2011-01-05 00:00:00 t 1 \N t \N t
1032 10 1 2011-01-06 00:00:00 t 1 \N t \N t
1032 10 0 2011-01-07 00:00:00 t 1 \N t \N t
1032 10 0 2011-01-08 00:00:00 t 1 \N t \N t
1032 10 0 2011-01-09 00:00:00 t 1 \N t \N t

As you can see "lukket" is false for all of the rows in oracle but has a t in copy.

As stated earlier I get the same result for the text fields containing True:False and ja:nej.

from ora2pg.

darold avatar darold commented on June 26, 2024

Thanks a lot Christian, your example helped a lot to find the bug. It is fixed now with commit 5edc4e5. Please download latest development code and give it a try.

Best regards,

from ora2pg.

bjornbak avatar bjornbak commented on June 26, 2024

That worked :)

Thank you!

from ora2pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.