Question Buffer-Copy

Is there any scenario where a "BUFFER-COPY" fails without giving any error? I am getting the updated value in the buffer until the previous line of the buffer-copy statement, but the record is not updated to the database. Its was not because of the write trigger, and also i have tried to trace if there is any error with "ERROR-STATUS". But errors were also not found.

Please help. Kindly let me know in case any additional information is required. Thanks.

Regards
Mani
 

Cringer

ProgressTalk.com Moderator
Staff member
It would help to see a snippet of your code I think. It's possible that the transaction scoping is wrong meaning that the record isn't committed when you think it is and that the errors aren't reported properly. I've had that happen before.
 
Hi Cringer,

Please find the code snippet below. Table names are modified.


FOR EACH customer WHERE customer.muuttunut = TRUE:
FIND FIRST t01ksktryhma WHERE
order.p2000_ksno = customer.p2000_ksno AND
order.kohryhtun = customer.kohryhtun AND
order.omfattning = "A":U
EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF AVAIL order THEN DO:
BUFFER-COPY customer TO order
ASSIGN order.datreg = TODAY
order.version = TIME
order.handlaggare = cur_user
order.datfrom = dtStart
NO-ERROR.
END.
 

Cringer

ProgressTalk.com Moderator
Staff member
For starters your For Each on Customer has no lock statement meaning it will be found share lock. You don't want this. The transaction will also be scoped to the whole for each, and therefore the changes won't actually be committed until after the for each has finished. I'm pretty certain that the triggers won't actually fire until this point either. You should no-lock your for each on customer. Then you should take off the NO-ERROR statements for testing purposes to see if they are hiding anything.
 

TomBascom

Curmudgeon
Hi Cringer,

Please find the code snippet below. Table names are modified.

Code:
FOR EACH customer WHERE customer.muuttunut = TRUE:
 
  FIND FIRST t01ksktryhma WHERE
    order.p2000_ksno = customer.p2000_ksno AND
    order.kohryhtun = customer.kohryhtun AND
    order.omfattning = "A":U
    EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
 
IF AVAIL order THEN
  DO:
    BUFFER-COPY customer TO order
      ASSIGN order.datreg = TODAY
        order.version = TIME
        order.handlaggare = cur_user
        order.datfrom = dtStart
    NO-ERROR.
  END.
 
end.

As Cringer mentioned you have omitted a NO-LOCK form your FOR EACH.

What does table "t01ksktryhma" have to do with anything? Did you forget to edit it's name to "order"? Or does the code really look like this?

Why is it a FIND FIRST? Is the WHERE criteria not unique? If it is not unique what do you do with the remaining records in the set? If it is unique why are you saying FIRST?

Assuming that "t01ksktryhma" was not supposed to be "ORDER" where do ORDER records come from?

How do you handle the case where no record is AVAILABLE()? Your code has no such handling so my guess is that it just silently skips such records. (Which is what you seem to be complaining about...) In other words the BUFFER-COPY is not failing -- it is never being asked to execute.
 

ezequiel

Member
I guess the thing is that you search on a table named "t01ksktryhma"

FIND FIRST t01ksktryhma WHERE .....EXCLUSIVE-LOCK NO-WAIT NO-ERROR.

And then you check the record availability of another table named "order":
IF AVAIL order THEN DO:
....

A newbie mistake.
 
Top