Page 1 of 1

Edit value of Persistent Data

Posted: Fri Aug 07, 2009 3:00 pm
by ConvertFromOldNGs
by John >> Fri, 17 Apr 2009 11:45:32 GMT

Hallo Jade programmer

I have a question .......
How the easiest way to edit or update a value of a persistent data instead of creating a new persistent data ?

e.g.
my persistent data Person

Name : Ronney
Id : R001

and I want to change to

Name : John Ronny
id : R001

Thanks for any clue

Re: Edit value of Persistent Data

Posted: Fri Aug 07, 2009 3:00 pm
by ConvertFromOldNGs
by Dean Cooper >> Fri, 17 Apr 2009 14:26:08 GMT

You can update an existing object simply by assigning new values to the required properties, just as you would for a transient object. The only difference is that when updating persistent objects, you must do so within a transaction. For example, the following code will update the name of the first Person object to "John Ronny":

vars
p : Person;begin

p := Person.firstInstance();
write "name before change = " & p.name;
beginTransaction;
p.name := "John Ronny";
commitTransaction;
// will output John Ronny
write "name after change = " & p.name;
end;

Dean.