Discussion:
OracleBulkCopy in PostGreSQL
Jain, Abhishek
2018-09-11 13:53:37 UTC
Permalink
HI Team,

What is the equivalent of OracleBulkCopy in PostgreSQL?

Thanks
Abhishek Jain
Mercer | 5th - 9th Floors, Building No. 14A, Sector-24 & 25, DLF Cyber City, Gurgaon - 122002, Haryana, India
+91 124 477 2156 | Mobile +91 9891968728 | ***@mercer.com<mailto:***@mercer.com>
www.mercer.com<http://www.mercer.com/> | Mercer India Private Limited


________________________________

This e-mail and any attachments may be confidential or legally privileged.
If you received this message in error or are not the intended recipient,
you should destroy the email message and any attachments or copies, and
you are prohibited from retaining, distributing, disclosing or using any
information contained herein. Please inform us of the erroneous delivery
by return e-mail. Thank you for your co-operation.
Mercer India Private Limited, 6th Floor, Building 14A,
DLF Cyber City Developers Limited, SEZ, Sector 24 & 25,
DLF Cyber City, Gurgaon, Haryana , India-122002.
Thomas Kellerer
2018-09-11 14:36:02 UTC
Permalink
What is the equivalent of OracleBulkCopy in PostgreSQL?             
Are you talking about the PL/SQL "bulk collect into" feature?

If not, what exactly is "OracleBulkCopy" doing? Can you show some code examples?

Thomas
Laurenz Albe
2018-09-12 12:52:11 UTC
Permalink
Post by Jain, Abhishek
What is the equivalent of OracleBulkCopy in PostgreSQL?
Probably COPY: https://www.npgsql.org/doc/copy.html

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Jain, Abhishek
2018-09-12 13:46:37 UTC
Permalink
Hi Again,



Following is the implementation that I have used using OracleBulkCopy wherein I have mapped the DB & data table columns [Highlighted in yellow]. But in the 'Text Copy' how can I specify these mappings.



public static void MYFunc (DataTable dt)

{

string error = string.Empty;

OracleConnection connection = CreateConnection();

connection.Open();

OracleBulkCopy bulkCopyRecords = new OracleBulkCopy(connection);

bulkCopyRecords.DestinationTableName = "EMPLOYEE ";

bulkCopyRecords.ColumnMappings.Add("EMPLID", "EMPLOYEE_ID");

bulkCopyRecords.ColumnMappings.Add("CATEGORY_ID", "CATEGORY_ID");

try

{

bulkCopyRecords.WriteToServer(dt);

}

catch (Exception ex)

{

error = ex.Source + " -> " + ex.Message + "<br /><br />" + ex.StackTrace + "<br />";

}

finally

{

DisconnectConnection(connection);

}

}



Thanks

Abhishek Jain

Mercer | 5th - 9th Floors, Building No. 14A, Sector-24 & 25, DLF Cyber City, Gurgaon - 122002, Haryana, India

+91 124 477 2156 | Mobile +91 9891968728 | ***@mercer.com

www.mercer.com | Mercer India Private Limited



-----Original Message-----
From: Laurenz Albe <***@cybertec.at>
Sent: Wednesday, September 12, 2018 6:22 PM
To: Jain, Abhishek <***@mercer.com>; pgsql-***@postgresql.org
Subject: Re: OracleBulkCopy in PostGreSQL
Post by Jain, Abhishek
What is the equivalent of OracleBulkCopy in PostgreSQL?
Probably COPY: https://www.npgsql.org/doc/copy.html



Yours,

Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com





________________________________

This e-mail and any attachments may be confidential or legally privileged.
If you received this message in error or are not the intended recipient,
you should destroy the email message and any attachments or copies, and
you are prohibited from retaining, distributing, disclosing or using any
information contained herein. Please inform us of the erroneous delivery
by return e-mail. Thank you for your co-operation.
Mercer India Private Limited, 6th Floor, Building 14A,
DLF Cyber City Developers Limited, SEZ, Sector 24 & 25,
DLF Cyber City, Gurgaon, Haryana , India-122002.
Laurenz Albe
2018-09-12 14:54:56 UTC
Permalink
Post by Jain, Abhishek
Following is the implementation that I have used using OracleBulkCopy
wherein I have mapped the DB & data table columns [Highlighted in yellow].
But in the 'Text Copy' how can I specify these mappings.
This will be quite different in the PostgreSQL case.
Read the documentation on COPY.

You will have to rewrite your code.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Jain, Abhishek
2018-09-12 14:59:38 UTC
Permalink
That’s the question - What's the code that I need to rewrite the code in postgre?

Thanks
Abhishek Jain
Mercer | 5th - 9th Floors, Building No. 14A, Sector-24 & 25, DLF Cyber City, Gurgaon - 122002, Haryana, India
+91 124 477 2156 | Mobile +91 9891968728 | ***@mercer.com
www.mercer.com | Mercer India Private Limited


-----Original Message-----
From: Laurenz Albe <***@cybertec.at>
Sent: Wednesday, September 12, 2018 8:25 PM
To: Jain, Abhishek <***@mercer.com>
Cc: pgsql-***@postgresql.org
Subject: Re: OracleBulkCopy in PostGreSQL
Post by Jain, Abhishek
Following is the implementation that I have used using OracleBulkCopy
wherein I have mapped the DB & data table columns [Highlighted in yellow].
But in the 'Text Copy' how can I specify these mappings.
This will be quite different in the PostgreSQL case.
Read the documentation on COPY.

You will have to rewrite your code.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com



________________________________

This e-mail and any attachments may be confidential or legally privileged.
If you received this message in error or are not the intended recipient,
you should destroy the email message and any attachments or copies, and
you are prohibited from retaining, distributing, disclosing or using any
information contained herein. Please inform us of the erroneous delivery
by return e-mail. Thank you for your co-operation.
Mercer India Private Limited, 6th Floor, Building 14A,
DLF Cyber City Developers Limited, SEZ, Sector 24 & 25,
DLF Cyber City, Gurgaon, Haryana , India-122002.
Loading...