Direct connection and OraLoader

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Direct connection and OraLoader

Post by jjeffman » Mon 09 Oct 2017 18:31

Hello,

I am using ODAC version 9.7,26 for C++Builder 6.0 Professional and I would like to know if it is possible to use TOraLoader when TOraSession is connected to the Oracle server in direct mode?

Can someone point me an example on using TOraLoader with C++ Builder ?

Thank you very much.

Best regards.

Jayme Jeffman Filho.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Direct connection and OraLoader

Post by MaximG » Wed 11 Oct 2017 13:08

You can run OraLoader when using ODAC Direct Mode with LoadMode = lmDML. For example, create the following table:

Code: Select all

CREATE TABLE MyLoadedTable (ID NUMBER, StrValue VARCHAR2 (128))
Then we implement the logic for populating the MyLoadedTable table to insert 10 entries in the OraLoaderGetColumnData handler:

Code: Select all

void __fastcall TForm1 :: OraLoaderGetColumnData (TObject * Sender, TDPColumn * Column, int Row, Variant & Value, bool & IsEOF)
{
switch (Column-> Index)
{
case 0: Value = Row; break;
case 1: Value = "Values" + IntToStr (Row); break;
default: Value = Null;
}
IsEOF = Row> 10;
}

Now you can use OraLoader:

Code: Select all

{
...
OraSession-> Connect ();
OraLoader-> LoadMode = lmDML;
OraLoader-> TableName = "MyLoadedTable";
OraLoader-> Load ();
...
}

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Re: Direct connection and OraLoader

Post by jjeffman » Wed 11 Oct 2017 14:09

Hello Maxim,

Thank you very much for answering me.

So, as I can learn from your answer, the "GetColumnData" event is the code point where I should put a "get next CSV line" to feed the columns data.

I have thought TOraLoader was an implementation of the work SQL*Loader does reading text files, but it does more as I can feed columns values from any source.

Is there a better approach to load text files data into Oracle tables ?

Best regards.

Jayme Jeffman Filho

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Re: Direct connection and OraLoader

Post by jjeffman » Wed 11 Oct 2017 17:34

Hello Maxim,

I would also like to know about the point of committing data to the database, as long as the component itself does not have any property which can indicate how many rows to load between commits.

Thank you very much.

Best regards.

Jayme Jeffman

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Direct connection and OraLoader

Post by MaximG » Mon 07 May 2018 14:23

The functionality you are interested in is absent in the TOraLoader component

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Re: Direct connection and OraLoader

Post by jjeffman » Mon 07 May 2018 14:45

Hi Maxim

Thank you very much for answering me.

I am filling up a TVirtualTable whitin a while loop and calling TOraLoader::LoadFromDataSet when the VirtualTable has a certain number of rows, to break the operation in blocks and let the users get acces to data just imported more quickly.

Best regards.

Jayme Jeffman

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Direct connection and OraLoader

Post by MaximG » Mon 07 May 2018 15:27

We are glad that you could find a necessary solution. Contact us with any questions about using our products

Post Reply