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?
FOR currenwholesaler IN SELECT "id" as currentid FROM "public"."wholesalers" WHERE "import_type_id" IS NOT NULL LOOP
EXECUTE 'COPY product_import_temp FROM /home/action/'|| currenwholesaler.currentid ||'import.csv' ;