I Have sample CSV file which contains 10 records.
So I want to upload the CSV file Thru stored procedure. Is it possible to do that way. This is my stored function.
FOR i IN 1..v_cnt LOOP
    SELECT idx_date,file_path INTO v_idx_date,v_file_path FROM cloud10k.temp_idx_dates
    WHERE is_updated IS FALSE LIMIT 1;
    COPY cloud10k.temp_master_idx_new(header_section) FROM v_file_path;
    DELETE FROM cloud10k.temp_master_idx_new WHERE header_section NOT ILIKE '%.txt%';
    UPDATE cloud10k.temp_master_idx_new SET CIK          = split_part( header_section,'|',1),
                                            company_name = split_part( header_section,'|',2),
                                            form_type    = split_part( header_section,'|',3),
                                            date_filed   = split_part( header_section,'|',4)::DATE,
                                            accession_number = replace(split_part(split_part( header_section,'|',5),'/',4),'.txt',''),
                                            file_path    = to_char(SUBSTRING(SPLIT_PART(v_file_path,'master.',2) FROM 1 FOR 8)::DATE,'YYYY')
   ||'/'||to_char(SUBSTRING(SPLIT_PART(v_file_path,'master.',2) FROM 1 FOR 8)::DATE,'MM')
   ||'/'||to_char(SUBSTRING(SPLIT_PART(v_file_path,'master.',2) FROM 1 FOR 8)::DATE,'DD')
   ||'/'||CONCAT_WS('.','master',SPLIT_PART(v_file_path,'master.',2) )
    WHERE header_section ILIKE '%.txt%';
 END LOOP;
But its not executing. Can someone suggest me how to do that..
Tanks, Ramesh
 
    