Question

Given a DecimalDataArea from JTOpen, when reading and writing to the data area, does the object on the AS400 get locked, preventing simultaneous writes to it from other applications that are on the AS400?

This is the sample code from the javadoc on how to read/write, etc.

// Prepare to work with the system named "My400".
AS400 system = new AS400("My400");

// Create a DecimalDataArea object.
QSYSObjectPathName path = new QSYSObjectPathName("MYLIB", "MYDATA", "DTAARA");
DecimalDataArea dataArea = new DecimalDataArea(system, path.getPath());

// Create the decimal data area on the system using default values.
dataArea.create();

// Clear the data area.
dataArea.clear();

// Write to the data area.
dataArea.write(new BigDecimal("1.2"));

// Read from the data area.
BigDecimal data = dataArea.read();

// Delete the data area from the system.
dataArea.delete();

http://javadoc.midrange.com/jtopen/com/ibm/as400/access/DecimalDataArea.html

Was it helpful?

Solution

No ... the data area operations are atomic, so no locking occurs unless you do it yourself.

Internally, the implementation actually uses CHGDTAARA to update the data area.

Wouldn't be a bad enhancement though.

OTHER TIPS

If you create the data are with an SQL CREATE SEQUENCE statement, then you can use a NEXT VALUE via JDBC. You can use a NEXT VALUE expression in SQL statements such as SELECT, INSERT, UPDATE, etc. It will read the value, increment it, update the SEQUENCE, and return the new value to you, and can be done under commitment control. The PREVIOUS VALUE expression will return the last value generated by a NEXT VALUE expression for that SEQUENCE during your current session.

Generally a numeric data area is used to manage generating a series of numbers. If that is the case here, then you'll be better off using a SEQUENCE.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top