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 8282317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:19:55+00:00 2026-06-08T10:19:55+00:00

I’ve been having a little problem with getting my program to follow records through

  • 0

I’ve been having a little problem with getting my program to follow records through a database dependent on the values within the record, simply put, this is what I’m trying to achieve.

This is a simplified version of the table I’m working with:

Record Name  |  Val1  | Val2  | Link |  Prev Link |
Rec1         |   5    |  3    | Rec2 |            |
Rec2         |   2    |  4    | Rec6 |  Rec1      |
Rec3         |   1    |  8    | Rec4 |            |
Rec4         |   1    |  1    |      |  Rec3      |
Rec5         |   8    |  3    |      |            |
Rec6         |   9    |  3    |      |  Rec2      |

My program needs to go through the above table, save the information against one particular record, go to it’s linked record, clear the values of the previous record and then add them onto the newer record (it should keep doing this till it reaches the end of the chain), as an example here is what should happen after running my program.

Record Name  |  Val1  | Val2  | Link |  Prev Link |
Rec1         |   0    |  0    | Rec2 |            |
Rec2         |   0    |  0    | Rec6 |  Rec1      |
Rec3         |   0    |  0    | Rec4 |            |
Rec4         |   2    |  9    |      |  Rec3      |
Rec5         |   8    |  3    |      |            |
Rec6         |   16   |  10   |      |  Rec2      |

The current procedure I am using can be found at the following location: http://pastebin.com/A10hW0C6

The main problem I am facing is that I cannot get the program to go through each record, follow any links and then return to the place that it left off to make sure it doesn’t miss any, also how can I make the program ignore records that it has already been over as part of a loop?

Any help would be appreciated 🙂

  • 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-06-08T10:19:57+00:00Added an answer on June 8, 2026 at 10:19 am

    Well, what you can do is to have a seperate query to hold the start-of-the-link records, such as:

    qry1.sql := 'select * from table where prev_link is null;';
    

    This gives

    Record Name  |  Val1  | Val2  | Link |  Prev Link |       
    Rec1         |   5    |  3    | Rec2 |            |       
    Rec3         |   1    |  8    | Rec4 |            |       
    Rec5         |   8    |  3    |      |            |       
    

    Then you can follow the result data set, seek/locate on the other query (query2), and apply your processing logic there.

    By the time you finished with the result date set, you are done. This, of course, assuming that your data is legit, i.e. no broken links, no circular links, etc.

    Some enhancement. You can add a column called ‘status’ to reflect the status of the record. For example, status = 0 means ‘Unprocessed’, ‘1’ means processed, ‘2’ means broken links, ‘3’ means circular link, etc. You can start by populating all status column with 0 (unprocessed).

    If you can not find the record by seeking/locating it in the ‘Link’ column (maybe somehow get deleted), then you can flag the status to ‘2’.

    Each time you follow a link, keep a track of the followed record. You can use a list, for example. Before following a record in the ‘Link’ column, check the list. If the record is in the list, then you have a circular link. Stop following, mark the status to ‘3’ (circular link), clear the list, and start with the next record in query1. Dealing with circular link is important, otherwise your program can stuck on it (never ended).

    When you finish processing a chain of links, then flag status to ‘1’ to all records in the list.

    You can make use of database transaction (begin transaction …end transaction), so when you encounter deadlink or circular link down the link-chain, you can rollback the changed values, and flag the status accordingly.

    After you finish, you can check the status column. If all ‘1’ means all good (processed). If not then you can decide what to do next.

    The column status can be used to filtered out already processed records on another sub sequent operations, so the query above can be altered:

    qry1.sql := 'select * from table where prev_link is null and status = 0;';
    

    Of course this is a preliminary strategy, and you can modify it to suit you.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I have a reasonable size flat file database of text documents mostly saved in
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a view passing on information from a database: def serve_article(request, id): served_article
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.