Simple join query

Posted by durgam4 on 07-May-2015 15:34

Hi ,

I am  New to 4gl

I am trying the following join but it is giving error. can someone correct it.. Thanks in advance.

 

for each item where item.seq_num = 1 and item.docid = 1,
for each batch where batch.batch_id = 'test' and item.batch_id = batch.batch_id no-lock

 

 

Posted by Thomas Mercer-Hursh on 07-May-2015 15:40

There should be only one FOR.

All Replies

Posted by Thomas Mercer-Hursh on 07-May-2015 15:40

There should be only one FOR.

Posted by James Palmer on 07-May-2015 15:43

You also need to specify a lock for each table in the predicate. Personally I also prefer to have the predicates this way around.

for each item no-lock where item.seq_num = 1 and item.docid = 1,

each batch where batch.batch_id = 'test' and batch.batch_id = item.batch_id no-lock

In future please post your Progress version and the errors you receive as it will help folks track down the issues more readily.

Posted by gabriel.lucaciu on 09-May-2015 13:53

Thomas helped on getting the answer, but I wonder why would you do that?

batch.batch_id = 'test' and item.batch_id = batch.batch_id

You already checked if batch.batch_id equals with 'test' and  then you check if it's also equal to item.batch_id.

If you need any help on learning ABL you can start from here:

documentation.progress.com/.../OpenEdge_latest

Posted by Thomas Mercer-Hursh on 09-May-2015 14:06

I suspect that there is a problem here since, as Gabriel points out, the condition can only be true when the item.batch_id = "test".   If that is true, you can skip looking at the item at all because you want batches where batch_id = "test", but since batch_id sound like a unique key, you would only need a find instead of a for each.

This thread is closed