#15 new
Mike Woodhouse

Oracle import broken

Reported by Mike Woodhouse | February 12th, 2009 @ 05:16 AM

(Probably merits its own ticket!)

As implemented, the oracle import function inherits the default behaviour, which I think produces a statement of the form:

INSERT INTO table(a,b) VALUES (1,2), VALUES(3,4) ...

Oracle doesn't like that. Actually, AFAICT Oracle doesn't really support arbitrary numbers of INSERTs of the ar-extensions type at all.

There's this:

INSERT ALL INTO tableA(v,w,x,id) VALUES (1,2,3,tablea_seq.nextval) INTO tableB(y,z,id) VALUES ('a', 'b',tableb_seq.nextval) SELECT 1 FROM DUAL;

...which is flexible but won't work for multiple inserts on the same table using a sequence (because the sequence is only referenced once).

There's more luck with wrapping the INSERTs in a PL/SQL block thus:

BEGIN INSERT INTO tableA(v,w,id) VALUES (1,2,tablea_seq.nextval); INSERT INTO tableA(v,w,id) VALUES (2,3,tablea_seq.nextval); INSERT INTO tableA(v,w,id) VALUES (4,5,tablea_seq.nextval); COMMIT; END

That works, but there's a maximum size to the command that doesn't depend on string size, but on the number of "Diana Nodes". That seems to reference a partially-compiled state of PL/SQL, which is an extended form of Ada. I suspect thinking AST wouldn't be too wrong. Anyhow, we're restricted to 64K of these things, but what code constructs constitute a node is not clear. On one test with a small table I was able to get up to about 7500 inserts and 870KB of text, so it should be too bad, although it does add an element of uncertainty.

I have a patch in the works, I just wanted to document where I'd got to in its own ticket.

There used to be an "array processing" facility using the Oracle libraries, but I haven't looked at it for almost 2 decades so I need to do some digging on that front. I don't know if it would be capable of being handled dynamically in any case.

Ho hum.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

ActiveRecord::Extension (aka ar-extensions) is a plugin to extend and
enhance the functionality of ActiveRecord. It starts by adding better
find support for ActiveRecord. It then adds mass data import
capabilities which are highly efficient and lastly it supports to_csv
functionality.

It also introduces a cool concept of creating easily extendable pieces
of ActiveRecord functionality, so developers don't have to understand
ActiveRecord internals or have the fear of breaking ActiveRecord
itself.

People watching this ticket

Pages