I am trying to write a pg plsqlfunction that will loop through a query and import CSV files but I cannot seem to get the formatting correct. what am I doing wrong here?
DECLARE
currenwholesaler RECORD;
csv_filename TEXT;
BEGIN
FOR currenwholesaler IN SELECT "id" as currentid FROM "public"."wholesalers" WHERE "import_type_id" IS NOT NULL LOOP
CSV
EXECUTE 'COPY product_import_temp FROM /home/action/'|| currenwholesaler.currentid ||'import.csv' ;
END LOOP;
END;