Edit value of Persistent Data

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Edit value of Persistent Data

Postby ConvertFromOldNGs » Fri Aug 07, 2009 3:00 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Edit value of Persistent Data

Postby ConvertFromOldNGs » Fri Aug 07, 2009 3:00 pm

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.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 10 guests

cron