Business Entity. Updating PK field.

Posted by OctavioOlguin on 15-Aug-2016 16:14

Hi.

I have a business entity, and I'm debugging a problema that arised 2 days ago...

One table has a solely index, on (Office + NumberEmployee). And we had to make a movement from one office to another, but the

onetable:UpdateOneTable(INPUT-OUTPUT dsEmployee).

Keeps ignoring the change on the Office field that I send by updating the temp-table inside datasaset...

So I wonder, as never saw this before....

Is the business entity not allowed to change the field on a PK?

Supposing that it considered the change to a PK invalid, why it won't throw an error? on that procedure have Catch for AppError and SysError.  Neither one catches error.

I'm missing something, but can't guess what....

TIA

Jorge

All Replies

Posted by egarcia on 15-Aug-2016 16:52

Hello Jorge,

Just some quick feedback.

Is this a Business Entity generated by default from Developer Studio? One that inherits from "BusinessEntity"?

Do you have a BEFORE-TABLE for the temp-table?

The key is that for this type of Business Entity, the primary key is used to identify the record to be updated.

You would need to specify the previous values of the primary key in the before-table and the new values in the after-table so that you can update the key. Otherwise, the might be specifying key fields for a record that may not exist.

I hope this helps,

Edsel

Posted by OctavioOlguin on 15-Aug-2016 16:53

ok!!!

I foresee that will be the problem...

Yes.. it's an automatic generated BI, and it has Before-Table...

Will do as you instruct... and post results...

Thanks

Posted by OctavioOlguin on 15-Aug-2016 18:30

I have struggled about this for a while now....

I have some questions about the handling of datasets.

Wondering if it is the way to go.

I have a dataset that gets all (or some) employees. (from a function on appserver.)

I handle the changing and displaying of them.

When time comes to update the primary key, I post the former values of them to another table in another dataset. (identical to the first one used to get the employees) and call the function that gets one employee using the original PK, so the before-table gets populated. Change the values of the PK, and then throw to the updateEmployee class on the appserver.

All this is beacuse I don't want to send all the employees again back, just to update one of them...

Am I right with this algorithm?

Edit....

On paper, it seemed the way to go... but It won't worked...

And don't have any log, nor error thrown...

Can't trace back to where/why it failed...  I put a message on the BI class, just before the

SUPER:UpdateData(DATASET dsEmployee BY-REFERENCE).

and to that point, the temp-tabe has the new value on the PK field.

(The second DS, was created with a

{procs\nom\inc\dwEmployee.i}
DEFINE TEMP-TABLE OneEmployee LIKE ttEmployee BEFORE-TABLE bOneEmployee.   // ttEmployee is the working dataset that gets all the employees on the wuery needed at one time or another
DEFINE DATASET dsOneEmployee  FOR   OneEmployee.

Posted by maura on 16-Aug-2016 08:54

Another thing to check is whether, when you created the Business Entity in the wizard,  you selected the "Write dataset before image" checkbox. You can verify this by looking at the catalog and verifying that the "useBeforeImage" property for the resource's operations is set to true. (Even though the temp-table is defined with the before-table, if this checkbox is not selected, the jsdo will not send before-image data back to the AppSErver)

If it's the case that "useBeforeImage" property is false, there is an existing bug in the BusinessEntity code where if you change the primary key, then the record will not be updated, and an error is *not" returned to the client.  In 4.3, we will be fixing this so that the BE will throw an exception to indicate to the client that the update failed.

Maura

Posted by OctavioOlguin on 16-Aug-2016 11:11

Thanks for your insight...!!

Just wonder, as I've never have seing it before, what is/where is the catalog?

At this point I'm just programming appserver - ABL clients.

TIA

This thread is closed