I'm wondering what the views are on what we may or may not expect from classes provided bij Progress?
After calling the OpenEdge.Net.HTTP.RequestBuilder the ERROR-STATUS is set and the GET-MESSAGE method returns error ConfigOption record not on file. (138).
When the builded request object is deleted the ERROR-STATUS is set and the GET-MESSAGE method returns error pbHeader record not on file. (138).
OpenEdge 11.7.2 64-bit Windows.
We (PSC) will patch the code to use the CAN-FIND+FIND or FIND+RELEASE pattern (usually the former) which will prevent this issue. In the short term you may be able to work around it - ugly, I know - by checking for message number 138 and ignoring it. You can use the errObj:GetMessageNumber(n) method.
Well, I for one would not mind if ERROR-STATUS or GET-MESSAGEs are "leaked". I would expect any relevant error to be returned as structured error-handling (as an exception, a child of Progress.Lang.Error). Furthermore, if I have code that depends on ERROR-STATUS etc I would make sure that it would be reset before I rely on it.
Just my 2c
I think it’s also stated in the documentation, you should only check/rely on error status/message right after a statement that uses No-ERROR.
I copied an existing batch procedure for a new batch. I kept getting a questionmark in my logfile with this:
IF ERROR-STATUS:ERROR OR RETURN-VALUE > "":U THEN DO:
MESSAGE "Error: ":U RETURN-VALUE .
RETURN "1":U .
END.
I'm using classes and structured error handling so I removed this code.
|
Someone once suggested a MISSING clause that would automatically create the record and assign the fields specified in the WHERE to the values used
Or what about
DO TRANSACTION:
CREATE x IF-MISSING WHERE [where- clause].
/* if the query fails, it creates a new record, if the query succeeds, then the x buffer is set to that record. */
ASSIGN x.field1 = value1 ....
END. /* transaction */
This is what we usually call UPSERT, or INSERT ON DUPLICATE KEY UPDATE. Either way there is no need for WHERE clause there, something along the line of…
I too, today just got this message.
Here is a snipe of the code I'm using to get there above error.
/** This conforms the SOAP 1.2 specification **/
ContentTypeHeader = SUBSTITUTE('application/soap+xml; action="&1"; charset=UTF-8':U,
SOAPAction).
AuthorizationHeader = SUBSTITUTE('&1 &2',
Classes.OAuth.OAuthAccessToken:AccessTokenType,
Classes.OAuth.OAuthAccessToken:AccessToken).
DEFINE VARIABLE oRequestBody AS String no-undo.
oRequestBody = NEW STRING(SOAPPayloadXML).
oRequest = RequestBuilder:Post(SOAPEndPointURL, oRequestBody)
:AddHeader('Authorization':U, AuthorizationHeader )
:HttpVersion ("HTTP/1.0")
:ContentType(ContentTypeHeader)
:Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
/** 200 OK Successful **/
IF oResponse:StatusCode EQ 200 AND
oResponse:ContentType EQ "application/soap+xml":U THEN
DO:
SOAPResponseXML = oResponse:Entity:ToString().
MESSAGE "SOAPResponseXML" SKIP
LENGTH(SOAPResponseXML).
ERROR-STATUS:ERROR = FALSE.
RETURN.
END.
ELSE
RETURN ERROR SUBSTITUTE("&1 &2", oResponse:StatusCode, oResponse:StatusReason).
Not that I’m arguing wether or not framework components should/could ‘pollute’ the error status or anything but the question is why do you even check the error-status if you don’t have any statement with NO-ERROR in that piece of code?
So.... what is the soultion to not getting this error message of pbHead not found?
We (PSC) will patch the code to use the CAN-FIND+FIND or FIND+RELEASE pattern (usually the former) which will prevent this issue. In the short term you may be able to work around it - ugly, I know - by checking for message number 138 and ignoring it. You can use the errObj:GetMessageNumber(n) method.
> On Feb 5, 2018, at 12:55 PM, Tim Kuehn wrote:
>
> The "FIND / IF NOT Avail / CREATE" pattern is so prevalent that I think it'd be worth considering as an addition to the language.
>
in SQL, this is known as an UPSERT - update if it exists, insert if it doesn’t.