My requirement is that I need to read the CSV file data and query it with one existing table in the Database to update some records. One approach I thought that to create a new table (temp) and load the CSV file into that table and query that with the existing table but I found that I don't have permission to create a new table or a directory (for external table approach).
Then I thought of doing this through a table variable but I'm not getting how to load the data into a table variable. I wrote the following query but it says
'invalid table name'
DECLARE
TYPE t IS TABLE OF VARCHAR2(15);
UPDATEPARTYID t;
BEGIN
SELECT *
BULK COLLECT INTO UPDATEPARTYID
FROM 'C:\Test\PartyID.csv';
END;
I used to work on Sql Server, so not much comfortable with Oracle. I'm using Sql Developer and Oracle11g, there are millions of records in the .csv file. Any help would be appreciated.
Update:
Structure of the Input File:
OldID,NewID
015110044200015,099724838000015
069167641100015,099724838000015
016093943300015,099728485000015
033264160300015,099728485000015
035968914300015,099728485000015
087580324300015,099728485000015
There is a column named PartyID (Varchar2(15)) in the existing table where I need to update those IDs with the new party ID, which are matching with the OldID of the input file.
The structure of the new target table will be:
From Party ID (Varchar2 15)
To Party ID (Varchar2 15)
Created Date Sysdate
Updated Date Sysdate
Status Char (1) S: Success, F: Failure
No.Of Tries Integer(3) Default value 0
If the number of tries are more than 3 then it will be marked as Failure.