Why do i get error 138 when doing a find followed by a create? - progress-4gl

I have the following code block which when run, gives error 138 and the create is actually failing. Any help would be appreciated.
FIND PSESCDel EXCLUSIVE-LOCK
WHERE PSESCDel.EmployeeCode = PSESC.EmployeeCode
AND PSESCDel.ServiceCoverRef = PSESC.ServiceCoverRef NO-ERROR.
IF NOT AVAILABLE PSESCDel THEN
DO:
IF PSESC.EmployeeCode = "0358" THEN
MESSAGE "RM NOT AV" PSESC.ServiceCoverRef.
CREATE PSESCDel.
ASSIGN PSESCDel.EmployeeCode = PSESC.EmployeeCode
PSESCDel.ServiceCoverRef = PSESC.ServiceCoverRef
PSESCDel.DeletedDate = TODAY.
IF PSESC.EmployeeCode = "0350" THEN
DO:
MESSAGE "RM IT CAME TO CREATE".
IF ERROR-STATUS:ERROR OR ERROR-STATUS:NUM-MESSAGES > 0 THEN DO:
MESSAGE "RM ERROR NUMBER" STRING(ERROR-STATUS:GET-NUMBER(1)).
MESSAGE "RM ERROR MESSAGE" ERROR-STATUS:GET-MESSAGE(1).
END.
END.
END.

The description of error 138 is: "The record you were looking for does not exist or cannot pass the selection given by your combination of WHERE, OF, and USING phrases." A record does not exist in your database that matches the EmployeeCode and ServiceCoverRef that you have in your FIND statement.
I'm guessing you are seeing this in your "RM ERROR NUMBER" message towards the bottom of your code snippet. The error that Progress produces is suppressed by the NO-ERROR phrase on your FIND statement. You might want to display those two values from the PSESC record and make sure they are what you expect them to be.

Related

How to prevent an Microsoft Access error message from populating when trying to close a form?

I have this form in Access with a bunch of drop down menu boxes. If I choose a value from the List and then change my mind and leave it blank again, click close, I always get this message:
the data has been changed
Another User edited this record and saved the changes
before you attempted to save your changes
Re-edit the record.
I have 3 different macros in the background running for
Deal type
Loan Exception Comments
Update Flags
I don't think those macros would affect anything to give that error. But can I write something so that it catches this error message and ignores it and proceeds to close when I click close?
The main form VBA has this code:
Private Sub Close_Click()
Me.FrmJobDetails.Form.Requery
Me.subform1.Form.Requery
If Me.FrmJobDetails.Form.Dirty = True Then 'what I tried adding
 me.FrmJobDetails.Form.Dirty = False 'what I tried adding
End If
If Me.subform1.Form.Dirty = True Then 'what I tried adding
 me.subform1.Form.Dirty = False 'what I tried adding
End If
DoCmd.SetWarnings (WarningsOff)
DoCmd.Save
entry
DoCmd.OpenQuery ("aqrySBORequestSiteDetail"), , acReadOnly
DoCmd.Close
DoCmd.SetWarnings (WarningsOn)
End Sub
In that code, with the comment "what I tried adding" is what I thought could prevent that error message from occurring.
Any suggestions?
I use this to handle the Write Conflict error (7787). When there's a write conflict, the first change goes through and the second one gets discarded.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7787 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub
Well... to skip it:
On Error Resume Next
At the top of the Macro will skip any commands with errors.
This won't fix the cause, but it will stop popping up the errors.
Thanks! I found this to work on my end. Same script, but DataErr 7878 instead.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7878 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub

Getting filemaker error "specified field is not found" during enter find and set field

I'm using the code to perform a find in filemaker and getting an error message that the specified field is not found. Does anyone see what I'm missing?
Enter Find Mode []
Set Field [Contact Data::car ; "--" ]
Set Error Capture [on]
Perform Find[]
There is nothing wrong with find step as the error capture set on just before this script step, so it should not produce an error message.
I think there is a problem with the related field (Contact Data::car) and it is not directly related to the current layout relationship.
The simplest way to check it is to run the same query manually.

Query console vs .xqy file

I am running the following code in the query console:
let $age := xs:integer(fn:days-from-duration(fn:current-date() - xs:date(/wl:leader/wl:dob/text())) div 365.25)
return $age
And the following in the .xqy file:
for $leader in /wl:leader
let $age := xs:integer(fn:days-from-duration(fn:current-date() - xs:date($leader/wl:dob/text())) div 365.25)
return $age
Now, both are similar, however when running on the query console I get the error: arg1 is not of type xs:duration?
I understand the error is cause by the time duration part in 'fn:current-date()', but why do I not face the same issue with .xqy file ?
As Mr Hunter points out, the difference in the code explains the error.
The second example passes one leader at a time into the expression.
The first examples passes all of the leaders into an expression that's expecting a single leader.
Hoping that helps,

Error message from filter array

So I have tried to get the error message from a filter array in a logic app workflow, this is what i have tried:
#body('Filter_array')['error']
#actions('Filter_array')['outputs']['body']['error']
Am I missing something or doing something wrong here?
Thanks.
UPDATE:
It says: "cannot be evaluated because property 'error' cannot be selected. ".
But i can clearly see the "error" in the body object in the output.
Ok so i managed to figure it out, i missed the fact that the array doesnt give me a single object as i thought i set it up to. so the solution was this:
#string(actions('Filter_array')['outputs']['body'][0]['error'])
Thanks for the help! :)
Can you try with #actions('Filter_array')['error'] ?
You have to distinguish 2 types of errors.
First error can occur during execution of your connector. Eg. The filter did not match. In this case, the connector executed and returns an output with an error-message.
Second error is a runtime error that can occur on the connector. For example if the input of your connector is invalid and the executing of the connector can't be triggered. In this case, the connector does not generate an output or result. In that case, you have to catch the exception with #actions('Filter_array')['error']

Progress 4GL BUFFER-COPY FAILS

DO ON ENDKEY UNDO, LEAVE:
FIND FIRST STUDENT NO-LOCK WHERE ST-ID = "TEST" NO-ERROR.
IF AVAILABLE STUDENT THEN
DO:
CREATE SCHOOL no-error.
BUFFER-COPY STUDENT EXCEPT STUDENT.Location
SCHOOL ASSIGN SCHOOL.Location = "MY LOCATION" NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE
" Error no " ERROR-STATUS:GET-NUMBER(i)
" txt: " ERROR-STATUS:GET-MESSAGE(i) VIEW-AS ALERT-BOX.
STOP.
END.
END.
END.
END.
This query is working fine but some time it was creating Empty Record. buffer-copy through some error that why it create empty record but i am not able verify the error because code was happen in LIVE. please help me how to FIX the problem. what type of error buffer-copy will through. 1000 times working fine 1 time it will FAIL. i know this is data defect but how to FIX. otherwise what type of errors BUFFER-COPY through.
Since you really don't know what errors occur - you need to start there.
To track general errors after a NO-ERROR statement you can do something like:
IF ERROR-STATUS:ERROR THEN DO:
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
/* Replace MESSAGE with some kind of logging */
MESSAGE
"Error number " i
" error no " ERROR-STATUS:GET-NUMBER(i)
" txt: " ERROR-STATUS:GET-MESSAGE(i) VIEW-AS ALERT-BOX.
END.
END.
Once you have the specific error number(s) you can search the Progress Knowledge Base for more information.
I would write the code as follow. If you use no-error always handle the error. When assigning/buffer copy check if no error then do a validate to confirm that triggers fire correctly. The error handling code can be put in its own procedure and then just called every time you wish to process error messages. (amended it a bit as I would write it, I do not always trap all errors, but error handling depends on various things, but it is a good way during testing to make sure code is setup correctly. Afterwards can remove error handling where not needed before deploying.)
FIND FIRST STUDENT NO-LOCK WHERE ST-ID = "TEST" NO-ERROR.
IF AVAILABLE STUDENT THEN
DO:
CREATE SCHOOL.
BUFFER-COPY STUDENT EXCEPT STUDENT.Location
TO SCHOOL ASSIGN SCHOOL.Location = "MY LOCATION"
NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
/* insert error handling - for example as as per #Jensd */
/* this is in case there is something wrong with buffer copy */
/* maybe a required field is left empty? */
END.
ELSE DO:
VALIDATE SCHOOL NO-ERROR. /* good idea as it raises any issues with triggers */
IF ERROR-STATUS:ERROR THEN
DO:
/* insert error handling - for example as as per #Jensd */
END.
END.
END.
I will not make a buffer-copy from one to other table stright, you might have index issues as i think you are having.
Better define a temp-table like the target table.
Then make a buffer copy to the temp-table.
Set the rigth key into the temp-table.
Then make a buffer copy from the temp table with the right key fields to the target table.
Try as follow:
Define temp-table t-school like school.
find first student no-lock and so on.
buffer-copy student to t-school.
Assign t-school.location = "whatever".
buffer-copy t-school to school.
Voila!
One possible way to debug the issue is to use "Recent Messages" under Help in AppBuilder provided you are able to run the code directly from it.