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

  • SEARCH
  • Home
  • 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 623731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:07:29+00:00 2026-05-13T19:07:29+00:00

I need some suggestions as to whether my idea is ok or not. I

  • 0

I need some suggestions as to whether my idea is ok or not. I have a situation where:

I need to do updates to every row of a table. There is some logic involved in the updation.
The logic is very simple, but it needs to be done for every row. There is a possiblity of every row getting updated.

Currently, I’m thinking about writing an ESQL/C program to do this. I’m thinking about loading every row into its
equivalent C structure through a select for update cursor, run the logic and commit.
What role does the HOLD keyword do on the cursor? I’m bit confused about the role of this.

These updates will be done during a system downtime period. The table contains approximately 130 million rows. It has
about 45 columns. Most of the columns are of type SMALLINT and INTEGER.

Am I on the right track? Suggestions welcome.

The database will be Informix (IDS version 11.50 FC6)

  • 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-13T19:07:29+00:00Added an answer on May 13, 2026 at 7:07 pm

    The key to making this work is to do the work in the server, rather than making the server select each row, pass it to the client, and then accept the data back from the client.

    UPDATE YourTable
       SET y = (CASE WHEN z > x THEN p ELSE y)
     WHERE key_column BETWEEN lo_val AND hi_val;
    

    The complicated part will likely be splitting the work into manageable sub-transactions; that’s what the ‘lo_val .. hi_val’ condition is about. If your logical logs are big enough to handle all 130 million rows being updated [about (2 * (row size + X) * number of rows), with X being a value around 20, I believe] with space to spare, then you can do it all at once. Clearly, this ‘updates’ every row.

    If you decide you must do it in the client (a mistake, but …), then:

    You use a SELECT cursor with HOLD so that it stays open and correctly positioned across transactions. You start a transaction, fetch a few thousand rows, updating each one as needed. Make sure you are using a prepared UPDATE statement; maybe you use a WHERE CURRENT OF condition.


    Do you suggest to put the update as part of the cursor in a stored procedure?

    No, though you could do it in a stored procedure. It depends in part on whether this is something you’re going to do on a regular basis; if so, maybe the stored procedure is a good idea, but I wouldn’t for a one-off exercise.

    It depends on how you are going to determine lo_val and hi_val. I’d probably use I4GL (because I’m fluent in it) and then I’d expect to prepare the UPDATE statement (with question marks in place of ‘lo_val’ and ‘hi_val’), and then I’d expect to execute it a number of times, each time forming a single statement transaction. So, if you decided to go with a ranges of lo_val..hi_val from 000000..099999, 100000..199999, … then you’d iterate:

    for i = 0 to 10000000 step 100000
        let j = i + 99999
        execute p_update using i, j
    end for
    

    In I4GL you would not absolutely need to use a prepared statement. If you have IDS 11, you can prepare statements in SPL. In earlier versions, and without much of a performance hit (I doubt if you could measure it reliably), you could simply use:

    CREATE PROCEDURE update_your_table()
        DEFINE lo_val, hi_val INTEGER;
    
        FOR lo_val = 0 TO 1000000 STEP 100000
            LET hi_val = lo_val + 99999;
            UPDATE YourTable
               SET y = (CASE WHEN z > x THEN p ELSE y)
             WHERE key_column BETWEEN lo_val AND hi_val;
        END FOR;
    
    END PROCEDURE;
    

    Untested code – use at your own risk!

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

Sidebar

Related Questions

I need some suggestions to implement a business rule - whether to keep it
I need some asp.net pagination code samples. I would like suggestions on open source
Need some regular expressions help. So far I have my code working to allow
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
I need some help joining two table. I've got: my_type_table , which has columns:
I am adding some checkboxes dynamically during runtime, and I need to know whether
Need some quick advice I am trying to access a object array but I
Need some help with Activerecord Querying in a has_many :through association. Model: Job class

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.