For Statement Scoping of Records

eddiej

New Member
OK, Here is a situation that I encounter frequently and have never been able to get a straight answer to.

Background:
A client application is writing records to table x. At the same time, a batch process which cycles every 5 minutes is reading records from table x utilizing the progress "For Each.." statement. It uses table x to update other database tables. When the other table updates are complete, the batch process flags the records in table x as processed.

When the "For Each" statement finishes, a 2nd "For Each" executes to delete any records that have been processed.

My question is this: When is the scope the set of records to be read by the "For Each" statement in the batch process determined? If at the begining of the batch process, table x contains 1000 records, and during record processing, 100 more are added, should the "For Each" statement proess all 1100 records? Only the original 1000? I've seen a few things happen with this:

1) All 1100 are processed.
2) The original 1000 are processed, leaveing the 100 new records for the next run.
3) The original 1000 are processed and some of the 100 are processed, leaving some of the new records for the next run.

Their doesn't seem to be any consistency to this. Outside of an obvious solution like a record counter, Is there any other way to control the scoping??

Sorry if this got a little long,

-Ed
 

gcampbell

Member
depending on where the records are added they may or may not be included into the current batch process.

You may want to use the PRESELECT EACH during the batch process to capture all records that are currently in the file. Then do your batch process. At the end of your batch process, do a quick can-find on your table to see if any more records exist and if so, process directly.

Later,
Gordon
 
Basic Progress 4GL here.
You are making a FOR EACH TableName, though what lock are you making (are you making any???).
A FOR EACH will ALWAYS execute a FOR EACH WITH An EXCLUSIVE LOCK. Try replacing your FOR EACH specifying the lock type.
Use FOR EACH TableName NO-LOCK, once AND only once you are ready to make record changes FIND the database record with EXCLUSIVE LOCK to edit.
This is basic Progress (OpenEdge).
Regards
 
mpowell_esq said:
Basic Progress 4GL here.
A FOR EACH will ALWAYS execute a FOR EACH WITH An EXCLUSIVE LOCK.
This is basic Progress (OpenEdge).
Regards

Actually, the default if unspecified is SHARE-LOCK. This default can be changed to NO-LOCK using the -NL parameter, although it is better to specify the lock in the FOR EACH statement.

This is basic Progress.


Please stop implying everyone who's posts you answer are stupid.

This is basic etiquette.


Lee
 
ps. I actually quite like your abrasive style, but you need to remember that some people can be intimidated by it, and may be reluctant to ask or answer questions.
 
Prevention better than cure

RE:
Actually, the default if unspecified is SHARE-LOCK. This default can be changed to NO-LOCK

I appreceiate that the default is ACTUALLY to find SHARE-LOCK, though it is better practise to believe that it is found EXCLUSIVE-LOCK, data integrety reasons. No real harm can be done by believing the record is in EXCLUSIVE-LOCK at that point.
Progress development is like any OTHER software programming - different people have their OWN styles.
Programming / development is not binary (YES/NO), interpretation of the language / environment becomes a factor. It is better to have GOOD practises, whether these are acurate beliefs is irrelevant.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
mpowell, you're really a piece of work ... those comebacks are even
more pathetic then your posts

reminds me of a friend of mine from my neighborhood we nick named "total lost"

i actually can't remember back to a single thing you said that makes
any sense and it's usually followed by "oh, i know that" comeback

RTFM ! just take 2 weeks and read the programming handbook. atleast
you won't be so lost and we could have some interesting discussions
 
Outa space

I am concenting to another place, a place in outa space, otherwise known as the planet your on, you are obviousley in ANOTHER world.

RE:

i actually can't remember back to a single thing you said that makes any sense.
* Learn to appreciate the 4GL, after a few courses it MAY become clear.

it's usually followed by "oh, i know that" comeback
* You obviousley have a visual problem. I have NEVER typed those words.

Trash time over. You obviousley have a REAL, problem. This forum is not the place to express inadequacies. Grow up when pubity kicks in, you may get over this.
 

Casper

ProgressTalk.com Moderator
Staff member
Sorry to say,

But it's also wise to know when you are wrong. It's good to give people information, but if it isn't the right information then don't give it or at least agree that you where wrong.
Even if it's just for the sake of clarity.

and:
Programming / development is not binary (YES/NO), interpretation of the language / environment becomes a factor. It is better to have GOOD practises, whether these are acurate beliefs is irrelevant.

Interpretation of the language can only be done if you interpret it with the right facts as a basis. If you for instance say that share-lock is the same as exclusive-lock and you treat it like that you can get problems like death-lock.

For me, It's hard to interpret facts different then from what they are....

And, by the way, the correctness of posts posted by Joey far exceed your replies. So think before you write. (Which I should do as well probably and don't get involved in this kind of discussion, but here you have it....)

Greetz,

Casper.
 
Before a HUGE argument occurs, I wish to clarify a few points that I "mis understood".
Realistically (in the real world (which I do not believe you are in), what harm can be done by believing a record is in Exclusive lock, when it is in share-lock???). We both agree (is it christmas!!!) that education will solve these problems. ProgressTalk is NOT here to educate - that is what the PSC courses are for. Progresstalk to simply to give guidance. To be guided that a record is in Exclusive lock, when actually it is in Share lock, is NOT imperative, it is guide guidence for future development.
Are you not able to distinguish between guidence, and facts??? When you are, then it is specelative whether you should comment in this forumn.
Regards
 
Childish > Go Away NOW >

I am bored and tired of explaining; I DO NOT and have NEVER said I believe a SHARE-LOCK is equal to EXCLUSIVE-LOCK. Before you start contradicting my comments be accurate - I have NEVER acknowledged that I believe a SHARE-LOCK is equal to EXCLUSIVE-LOCK. You continually and repeatedly imply that I do. You have also NEVER answered my first question in THIS INSTANCE, what harm can be done?? Before you start contradicting, contradict my guidance with COMPLETE FACTS, and interoperate accurately my comments and NOT WHAT YOU misguidedly believe they are.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
You know what you're absolutely right. I should have also listened to Lee Curzon.

M. Powell I'm sorry I promise it will never happen again. You're doing really good.
 

Casper

ProgressTalk.com Moderator
Staff member
I agree, MPowell, you are absolutely right and saying it in your words:
'That's a good practice whether these are acurate beliefs is irrelevant'.

HTH,

Casper.
 
As the person who threw the first bun here, can I just say (in as condescending a manner as possible):

Martin, Generally I like your posts on this forum. They are not always the most authoritative, but they have an emotional, scattergun energy which makes ProgressTalk a more fun, boisterous place to be than more earnest, staid forums (no names).

All I'm asking is that you keep the 'Basic Progress' (ie. 'RTFM') type comments away from the ProgressTalk newbies, as it isn't a very welcoming approach. It didn't make sense anyway here, as a sensible question was posed.

You can get cocky with me (and other abrasive posters) anytime, though - as long as Chris allows it. And if I have the time, I'll take pleasure in showing you the error of your ways.

Lee
 

John Nebi

Member
I'm convinced that mPowell_esq is a fictional hero, planted by Chris to enhance the entertainment value of this forum. His sentences are too hilariously constructed, his spelling errors too calculatedly amusing for him to be an actual person. But then again, reality can be funnier than fiction ... :awink:
 
John Nebi said:
His sentences are too hilariously constructed, his spelling errors too calculatedly amusing for him to be an actual person.

There can be various reasons for this: English as second language, cultural differences, educational shortfalls, dyslexia, other impairments and disabilities. I hope we won't get too critical on that front.

I just want him to be nice to newcomers.


Lee 'Mr. Reasonable' Curzon
 

John Nebi

Member
Well, I suppose those are possiblities, and in the spirit of political correctness, your point is well taken. However, Mr. mPowell seems to occasionally demonstrate the ability to post reasonably coherent sentences when he feels like it. After all, if he wants us to take his limited understanding of the Progress language seriously, he could start with taking the English language seriously. I do sense the same cavalier approach. While I'm no great linguist myself, I do believe one of the casualties of the internet communications age seems to be the English language, even with English speakers.
 

John Nebi

Member
Well, then perhaps we could all use Esperanza. BTW I see i mispelled possibilities. No doubt I will be hearing from Mr. Powell.
 
Dude Chill

The internet demenstrates 1 thing. Spelling is irrelevant. The internet is Phonetic, so long as users can easily understand the comprihension that is all that is required.
 
Top