Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6475037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:27+00:00 2026-05-25T06:39:27+00:00

After loading data from a csv into an existing Postgres table, I will have

  • 0

After loading data from a csv into an existing Postgres table, I will have duplicate records that need to be merged. To do this, I plan on using a stored procedure that does the following:

   current_record airports%ROWTPE;
   new_record airports%ROWTYPE

   FOR current_record in SELECT * from airports ORDER BY iko  LOOP
       SELECT * into (STRICT) new_record from airports where iko=current_record.iko AND oid < current_record.oid
         -- IS IT POSSIBLE TO enumerate over each field as follows?
            FOR int i = 0; i < new_record.fields.count; i++ LOOP
               IF new_record.field[i] IS NOT NULL THEN current_record.field[i] =
               new_record.field[i] 
            END LOOP;
   END LOOP;

Can I enumerate over fields using the FOR inner loop as shown above or will I have to hardcode my change logic for each field in the table? There are about 70 columns.

Other better ways on how to do this will help as well.

TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:39:28+00:00Added an answer on May 25, 2026 at 6:39 am

    There is no direct support for that. However you can query the system catalogs from within your function. But that won’t make things faster.

    Here is an example on how to do it in a trigger. That might get you started in the right direction.

    http://wiki.postgresql.org/wiki/PL/pgSQL_Dynamic_Triggers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have retrieved data from Json URL and displayed it in a table view.
I have application reads in data from text file. Recently I realized that I
I have a SL application that reads some data from the database, which I
I'm loading data from my database into a DataTable, and one of the columns
I'm loading data from TextFlow to spark:TextArea. In TextFlow i have 'a href' elements.
I'm working with a Matlab API that loads data from a proprietary format into
I have a little iPhone app that loads data from a web service. To
I have a form that contains several comboxes that their data is coming from
I'm working on an iPad app that downloads a CSV file from the web
I have a function that loads a SVG Dom from a file. Currently, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.