Project

General

Profile

ALIAS (Function)

ALIAS ( index )

public static character alias(NumberType index)

public static character alias(int index)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Returns the alias at the specified index among all created aliases. When the first alias is created, it receives the index 1, second alias receives index 2 and so on. If an alias has been deleted, then indexes of aliases which were created after it, will be decreased.

index

1-based index of alias among all created aliases.

Returns

Alias at the given index or the unknown value if there is no corresponding alias.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message ALIAS(1).

Converted example:

ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.alias(new integer(1)));

AMBIGUOUS (Function)

AMBIGUOUS ( dmo )

public static logical wasAmbiguous(DataModelObject dmo)

public static boolean _wasAmbiguous(DataModelObject@dmo@)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Returns a TRUE value if the last FIND (unique) statement for a particular record buffer found more than one record that met the specified criteria.

dmo

The record buffer you want to check.

Returns

TRUE value if the last FIND (unique) statement for a particular record buffer found more than one record that met the specified criteria.

Example:

find book where price = 10 no-error.
if available(book) then message "The target book was found!".
else do:
  if ambiguous(book) then message "There are several books that match the given criteria.".
  else message "Cannot find the target book!".
end.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
...
ErrorManager.silentErrorEnable();
new FindQuery(book, "book.price = 10", null, "book.bookId asc").unique();
ErrorManager.silentErrorDisable();
if (RecordBuffer._isAvailable(book))
{
   message("The target book was found!");
}
else
{
   if (RecordBuffer._wasAmbiguous(book))
   {
      message("There are several books that match the given criteria.");
   }
   else
   {
      message("Cannot find the target book!");
   }
}

AVAILABLE (Function)

AVAILABLE ( dmo )

public static logical isAvailable(DataModelObject dmo)

public static boolean _isAvailable(DataModelObject dmo)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Returns a TRUE value if the record buffer contains a record and returns a FALSE value if the record buffer is empty.

dmo

The record buffer you want to check.

Returns

A TRUE value if the record buffer contains a record and returns a FALSE value if the record buffer is empty.

Example:

message available(book). /* displays “no” */
find first book.
message available(book). /* displays “yes” */

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
...
message(RecordBuffer.isAvailable(book));                                 /* displays “no” */
new FindQuery(book, (String) null, null, "book.bookId asc").first();
message(RecordBuffer.isAvailable(book));                              /* displays “yes” */

CONNECTED (Function)

CONNECTED ( name )

public           static logical connected(character name)

public static logical connected(String name)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Tells whether the database is connected.

name

Logical database name or alias. Logical database name is the one that was specified into the CONNECT statement. Alias of the target database is the one which was specified into CREATE ALIAS statement.

Returns

logical true if the database with the given logical name or alias is connected.

Example:

CONNECT p2j_test -ld some_name -H localhost -S 3333.
CREATE ALIAS some_alias FOR DATABASE some_name .
IF CONNECTED("some_name") then message "some_name connected".
IF CONNECTED("some_alias") then message "some_alias connected".

Converted example:

ConnectionManager.connect("p2j_test", "some_name", "localhost", 3333);
ConnectionManager.createAlias("some_alias", "some_name");
if ((ConnectionManager.connected("some_name")).booleanValue())
{
    message("some_name connected");
}
if ((ConnectionManager.connected("some_alias")).booleanValue())
{
    message("some_alias connected");
}

CURRENT-CHANGED (Function)

CURRENT-CHANGED(record)

public static logical currentChanged(DataModelObject dmo)

(method of com.goldencode.p2j.persist.RecordBuffer)

Returns TRUE if the copy of the record in the buffer after executing a FIND CURRENT or GET CURRENT differs from the copy of the record in the buffer before executing the FIND CURRENT or GET CURRENT.

That is, if the current application changes the record, but no other user changes the record during its scope in the current application, CURRENT-CHANGED returns FALSE.

record

The name of a table or buffer.

Returns:

TRUE if the copy of the record in the buffer after executing a FIND CURRENT or GET CURRENT differs from the copy of the record in the buffer before executing the FIND CURRENT or GET CURRENT.

Example:

FIND CURRENT Book EXCLUSIVE-LOCK.
IF CURRENT-CHANGED Book THEN DO:
   MESSAGE "This record has been changed by another user" 
      SKIP "Please re-enter your changes." VIEW-AS ALERT-BOX.
   DISPLAY Book.Name Book.Author WITH FRAME upd.
   RETURN NO-APPLY.
END.
ASSIGN Book.Name Book.Author.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
new FindQuery(book, (String) null, null, "Book.id asc", LockType.EXCLUSIVE).current();
if ((RecordBuffer.currentChanged(book)).booleanValue())
{
   messageBox(new Object[]
   {
      "This record has been changed by another user",
      new SkipEntity(),
      "Please re-enter your changes." 
   }, ALERT_MESSAGE, BTN_OK, null);
   FrameElement[] elementList0 = new FrameElement[]
   {
      new Element(new FieldReference(customer, "Name"), updFrame.widgetName()),
      new Element(new FieldReference(customer, "Author"), updFrame.widgetBalance())
   };
   updFrame.display(elementList0);
   returnConsume();
}
RecordBuffer.startBatch();
updFrame.assignScreenValue(new Element(new FieldReference(customer, "Name"), updFrame.widgetName()));
updFrame.assignScreenValue(new Element(new FieldReference(customer, "Author"), updFrame.widgetBalance()));
RecordBuffer.endBatch();

CURRENT-VALUE (Function)

CURRENT-VALUE(sequence[, database])

public static int64 currentValue(String seqName)

public static int64 currentValue(String seqName, String database)

(methods of com.goldencode.p2j.persist.SequenceManager)

Returns the current INT64 value of a sequence defined in the Data Dictionary.

seqName

An identifier that specifies the name of a sequence defined in the Data Dictionary.

database

An identifier that specifies the logical name of the database in which the sequence is defined. The database must be connected. You can omit this parameter if the sequence name is unambiguous. If a sequence with this name exists in more than one connected database, then you must specify database.

Returns:

The last value set with either the CURRENT-VALUE statement or successfully returned by the the NEXT-VALUE function, or of the dynamic forms of them.

Example:

DISPLAY CURRENT-VALUE(my-seq-1) CURRENT-VALUE(my-seq-1, p2j_test).

Converted example:

FrameElement[] elementList1 = new FrameElement[]
{

   new Element(SequenceManager.dynamicCurrentValue("my-seq-1"), frame0.widgetExpr1())
   new Element(SequenceManager.dynamicCurrentValue("my-seq-1", "p2j_test"), frame0.widgetExpr2())
};

frame0.display(elementList1);

CURRENT-VALUE (Statement)

CURRENT-VALUE(sequence[, database]) = <expression>

public static void setValue(String seqName, long newValue)

public static void setValue(String seqName, long newValue, String database)

public static void setValue(String seqName, int64 newValue)

public static void setValue(String seqName, int64 newValue, String database)

(methods of com.goldencode.p2j.persist.SequenceManager)

Resets the current integer value of a sequence defined in the Data Dictionary.

seqName

An identifier that specifies the name of a sequence defined in the Data Dictionary.

database

An identifier that specifies the logical name of the database in which the sequence is defined. The database must be connected. You can omit this parameter if the sequence name is unambiguous. If a sequence with this name exists in more than one connected database, then you must specify database.

expression

An integer expression assigned as the current value of the specified sequence. If expression is outside the boundary set by the initial value (at one end) and the lower limit or upper limit (at the other end) for the sequence, the AVM returns an error, and the sequence value remains unchanged.

Example:

CURRENT-VALUE(my-seq-1) = 10.
CURRENT-VALUE(my-seq-1, p2j_test) = 5 + 5.

Converted example:

SequenceManager.setValue("my-seq-1", 10);
SequenceManager.setValue("my-seq-1", plus(5, 5), "p2j_test");

CURRENT-RESULT-ROW (Attribute and Function)

referent:CURRENT-RESULT-ROW

CURRENT-RESULT-ROW ( query-name )

public integer currentRow()

(method of com.goldencode.p2j.persist.P2JQuery)

Progress-compatible function that returns the 1-based index of the current row in the result set. This is the index of the entry at or before which the cursor currently is positioned.

When used as a function, query-name is a character expression which evaluates to a open, scrollable query.

Returns

Unknown value if the query is not open or result set is empty. 1 if the query is positioned before the first record. A value 1 greater than the number of rows in the query result set if the query is positioned beyond the last record. Otherwise returns the number of rows in the query result set.

Example:

def query q for book scrollable.

open query q preselect each book.
message string(query q:current-result-row). /* attribute */
message string(current-result-row(q)). /* function */

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper(true);
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
message(valueOf(query0.currentRow()));
message(valueOf(query0.currentRow()));

query0.close();

DATASERVERS (Function)

DATASERVERS ( )

public static character getDataServerList()

(method of com.goldencode.p2j.util.EnvironmentOps)

Gets the list of the data servers available in Progress compatible environment. The value returned may have been found via a search algorithm that is account (user or process) specific or group specific within the current server or a global default for all servers. The implementation iteratively looks up the directory node under:

/server/<serverID>/runtime/<account_or_group>/dataServers

If no user/process or group nodes are present, then this is checked:

/server/<serverID>/runtime/default/dataServers

If no /server/<serverID>/runtime node exists, this is checked (it is the global default area for all servers):

/server/default/runtime/<account_or_group>/dataServers

Finally, if no user/process or group nodes are present in the global default area, then this is checked:

/server/default/runtime/default/dataServers

If no value is found via this lookup, then the default value of &quot;PROGRESS,ORACLE,AS400,ODBC,MSS" will be returned.

Returns

The list of data servers.

Example:

message "Defined dataservers:" dataservers.

Converted example:

message(new Object[]
{
    "Defined dataservers:",
    EnvironmentOps.getDataServerList()
});

DBNAME (Function)

DBNAME ( )

public static character dbName()

(method of com.goldencode.p2j.persist.ConnectionManager)

Get the name of the connected database in this context. If more than one, return the first.

Returns

First or only connected database, or unknown value if none.

Example:

message dbname.

Converted example:

message(ConnectionManager.dbName());

DBPARAM (Function)

DBPARAM(integer-expression | logical-name | alias)

public static character dbParam(int index)

public static character dbParam(NumberType index)

public static character dbParam(String nameOrAlias)

public static character dbParam(character nameOrAlias)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Returns, as a character string, a comma-separated list of the parameters used to connect to the database. The parameters returned by this method generally will not match those returned by the original 4GL implementation, since we don't support any others than those handled by ConnectionManager.connect(Object... args).

integer-expression

The sequence number of a database the Progress session is connected to. For example, DBPARAM(1) returns information on the first database the Progress session is connected to, DBPARAM(2) returns information on the second database the Progress session is connected to, etc. If you specify a sequence number that does not correspond to a database the Progress session is connected to, the DBPARAM function returns the unknown value (?).

logical-name or alias

These forms of the DBPARAM function require a character expression as a parameter. An unquoted character string is not permitted. If the parameter is an alias or the logical name of a connected database, then Progress returns the comma-separated parameter list. Otherwise, it returns the unknown value (?).

Returns:

A comma-separated list of the parameters used to connect to the database.

Example:

MESSAGE DBPARAM(1).
MESSAGE DBPARAM("p2j_test").
MESSAGE DBPARAM("some_alias").

Converted example:

message(ConnectionManager.dbParam(new integer(1)));
message(ConnectionManager.dbParam(new character("p2j_test")));
message(ConnectionManager.dbParam(new character("some_alias")));

DBRESTRICTIONS (Function)

DBRESTRICTIONS ( name | index [ , table ] )

public static character dbRestrictions(NumberType index)

public static character dbRestrictions(int index)

public static character dbRestrictions(NumberType index, character table)

public static character dbRestrictions(NumberType index, String table)

public static character dbRestrictions(int index, character table)

public static character dbRestrictions(int index, String table)

public static character dbRestrictions(character name)

public static character dbRestrictions(String name)

public static character dbRestrictions(character name, character table)

public static character dbRestrictions(character name, String table)

public static character dbRestrictions(String name, character table)

public static character dbRestrictions(String name, String table)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Legacy function.

In 4GL it returns a character string that describes features that are not supported for this database or for the specific table. In FWD it returns an empty string.

name

Logical name or alias of the target database.

index

The index of the target database among all connected databases. When the first database is connected, it receives the index 1, second database receives index 2 and so on. If a database has been disconnected, then indexes of the databases which were connected after it, will be decreased.

table

Makes the function return unsupported features for the specified table. Ignored in FWD.

Returns

In FWD, if database with the given logical name, alias or index exists, an empty string is returned. Otherwise the unknown value is returned.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message DBRESTRICTIONS(1).
message DBRESTRICTIONS("p2j_test").
message DBRESTRICTIONS("some_alias").

Converted example:

ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.dbRestrictions(new integer(1)));
message(ConnectionManager.dbRestrictions(new character("p2j_test")));
message(ConnectionManager.dbRestrictions(new character("some_alias")));

DBTYPE (Function)

DBTYPE ( name | index )

public static character dbType(NumberType index)

public static character dbType (int index)

public static character dbType (character name)

public static character dbType (String name)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Returns, as a character string, the type of the database which corresponds the input parameter. In FWD the only returned type is “PROGRESS”.

name

Logical name or alias of the target database.

index

The index of the target database among all connected databases. When the first database is connected, it receives the index 1, second database receives index 2 and so on. If a database has been disconnected, then indexes of the databases which were connected after it, will be decreased.

Returns

In FWD, if database with the given logical name, alias or index exists, “PROGRESS” is returned. Otherwise the unknown value is returned.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message DBTYPE(1).
message DBTYPE("p2j_test").
message DBTYPE("some_alias").

Converted example:

ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.dbType(new integer(1)));
message(ConnectionManager.dbType (new character("p2j_test")));
message(ConnectionManager.dbType (new character("some_alias")));

DYNAMIC-CURRENT-VALUE (Function)

DYNAMIC-CURRENT-VALUE(sequence, database)

public static int64 dynamicCurrentValue(String seqName, String database)

public static int64 dynamicCurrentValue(character seqName, String database)

public static int64 dynamicCurrentValue(String seqName, character database)

public static int64 dynamicCurrentValue(character seqName, character database)

(methods of com.goldencode.p2j.persist.SequenceManager)

Returns the current INT64 value of a sequence defined in the Data Dictionary.

seqName

A character expression that evaluates to the name of a sequence defined in the Data Dictionary.

database

A character expression that evaluates to the logical name of the database in which the sequence is defined. The database must be connected.

Returns:

The last value set with either the CURRENT-VALUE statement or successfully returned by the the NEXT-VALUE function, or of the dynamic forms of them.

Example:

DISPLAY DYNAMIC-CURRENT-VALUE("my-seq-1", "p2j_test").

Converted example:

FrameElement[] elementList1 = new FrameElement[]
{

   new Element(SequenceManager.dynamicCurrentValue("my-seq-1", "p2j_test"), frame0.widgetExpr1())
};

frame0.display(elementList1);

DYNAMIC-CURRENT-VALUE (Statement)

DYNAMIC-CURRENT-VALUE(sequence, database) = <expression>

public static void dynamicSetValue(String seqName, long newValue)

public static void dynamicSetValue(String seqName, long newValue, String database)

public static void dynamicSetValue(String seqName, int64 newValue)

public static void dynamicSetValue(String seqName, int64 newValue, String database)

(methods of com.goldencode.p2j.persist.SequenceManager)

Resets the current integer value of a sequence defined in the Data Dictionary.

seqName

An identifier that specifies the name of a sequence defined in the Data Dictionary.

database

An identifier that specifies the logical name of the database in which the sequence is defined. The database must be connected.

expression

An integer expression assigned as the current value of the specified sequence. If expression is outside the boundary set by the initial value (at one end) and the lower limit or upper limit (at the other end) for the sequence, the AVM returns an error, and the sequence value remains unchanged.

Example:

CURRENT-VALUE(my-seq-1) = 10.
CURRENT-VALUE(my-seq-1, p2j_test) = 5 + 5.

Converted example:

SequenceManager.dynamicSetValue("my-seq-1", 10);
SequenceManager.dynamicSetValue("my-seq-1", plus(5, 5), "p2j_test");

DYNAMIC-NEXT-VALUE (Function)

DYNAMIC-NEXT-VALUE(sequence, database)

public static int64 dynamicNextValue(String seqName, String database)

public static int64 dynamicNextValue(character seqName, String database)

public static int64 dynamicNextValue(String seqName, character database)

public static int64 dynamicNextValue(character seqName, character database)

(methods of com.goldencode.p2j.persist.SequenceManager)

Returns the next INT64 value of a sequence, incremented by the positive or negative value defined in the specified database.

If sequence is a cycling sequence, and the DYNAMIC-NEXT-VALUE function increments the sequence beyond its upper limit (for positive increments) or decrements the sequence beyond its lower limit (for negative increments), the function sets and returns the initial value defined for the sequence.

If sequence is a terminating sequence, and the DYNAMIC-NEXT-VALUE function attempts to increment the sequence beyond its upper limit (for positive increments) or decrement the sequence beyond its lower limit (for negative increments), the function returns the Unknown value (?) and leaves the current sequence value unchanged. Once a sequence terminates, DYNAMIC-NEXT-VALUE continues to return the Unknown value (?) for the specified sequence until it is reset to a new value with the DYNAMIC-CURRENT-VALUE statement, or its definition is changed to a cycling sequence. After changing the sequence definition to cycle, the first use of DYNAMIC-NEXT-VALUE for the sequence sets and returns its initial value.

seqName

A character expression that evaluates to the name of a sequence defined in the Data Dictionary.

database

A character expression that evaluates to the logical name of the database in which the sequence is defined. The database must be connected.

Returns:

The next INT64 value of a sequence, incremented by the positive or negative value defined in the specified database.

Example:

DISPLAY DYNAMIC-NEXT-VALUE("my-seq-1", "p2j_test").

Converted example:

FrameElement[] elementList1 = new FrameElement[]
{

   new Element(SequenceManager.dynamicNextValue("my-seq-1", "p2j_test"), frame0.widgetExpr1())
};

frame0.display(elementList1);

FIRST (Function)

FIRST           ( break-group )

public logical isFirst()

(method of com.goldencode.p2j.persist.PresortQuery)

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the first iteration of that block.

In FWD these blocks are backed by queries which are iterated in conformity with block iterations. Therefore in FWD one should call the instance method of the presort query which backs the target block. This method returns TRUE if the current query result row is the first row.

break-group

Not used in FWD. In 4GL it allows to identify the target block.

Returns

In 4GL returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK

block is the first iteration of that block. In FWD returns TRUE if the current query result row is the first row.

Example:

for each book break by book.book-title:
  if first(book.book-title) then hide all.
  display book.book-title with frame f1 10 down.
end.

Converted example:

forEach("loopLabel0", new Block()
{
    PresortQuery query0 = null;

      FieldReference byExpr0 = new FieldReference(book, "bookTitle");

      public void init()
      {
           ...
         query0 = new PresortQuery(book, (String) null, null, "book.bookId asc");
         query0.enableBreakGroups();
         query0.setNonScrolling();
         query0.addSortCriterion(byExpr0);
      }

      public void body()
      {
         query0.next();
         if ((query0.isFirst()).booleanValue())
         {
            hideAll(false);
         }

         FrameElement[] elementList0 = new FrameElement[]
         {
            new Element(new FieldReference(book, "bookTitle"), f1Frame.widgetBookTitle())
         };

         f1Frame.display(elementList0);
      }
});

FIRST-OF (Function)

FIRST-OF ( break-group )

public logical isFirstOfGroup( break-group )

(method of com.goldencode.p2j.persist.PresortQuery)

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the first iteration for a new break group.

In FWD these blocks are backed by queries which are iterated in conformity with block iterations. Therefore in FWD one should call the instance method of the presort query which backs the target block. This method returns TRUE if the current query result row is the first row within the specified break group.

break-group

In 4GL it is the name of a field or expression you name in the block header with the BREAK BY option that identifies the target break group. In FWD it is the reference to a Resolvable object that identifies the target break group and which was specified previously when invoking addSortCriterion on the presort query which backs the target block.

Returns

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the first iteration for a new break group. In FWD this function returns TRUE if the current query result row is the first row within the specified break group.

Example:

for each book break by book.publisher:
  if first-of(book.publisher) then clear all.
  display book.publisher
          book.book-title with frame f1 10 down.
end.

Converted example:

forEach("loopLabel0", new Block()
{
   PresortQuery query0 = null;

   FieldReference byExpr0 = new FieldReference(book, "publisher");

   public void init()
   {
      ...
      query0 = new PresortQuery(book, (String) null, null, "book.publisher asc");
      query0.enableBreakGroups();
      query0.setNonScrolling();
      query0.addSortCriterion(byExpr0);
   }

   public void body()
   {
      query0.next();
      if ((query0.isFirstOfGroup(byExpr0)).booleanValue())
      {
         clearAll(false);
      }

      FrameElement[] elementList0 = new FrameElement[]
      {
         new Element(new FieldReference(book, "publisher"), f1Frame.widgetPublisher()),
         new Element(new FieldReference(book, "bookTitle"), f1Frame.widgetBookTitle())
      };

      f1Frame.display(elementList0);
   }
});

GATEWAYS (Function)

GATEWAYS ( )

public static character getDataServerList()

(method of com.goldencode.p2j.util.EnvironmentOps)

Alias for DATASERVERS function. See DATASERVERS for details.

Returns

The list of data servers.

Example:

message "Defined gateways:" gateways.

Converted example:

message(new Object[]
{
    "Defined dataservers:",
    EnvironmentOps.getDataServerList()
});

GET-FIRST (Method)

referent:GET-FIRST ( NO-LOCK | SHARE-LOCK [, NO-WAIT] | EXCLUSIVE-LOCK [, NO-WAIT] )

public void first()

public void first(LockType lockType)

(methods of com.goldencode.p2j.persist.P2JQuery)

Navigate to the first record which meets the query criteria and retrieve it into its record buffer. Use the default substitution parameters and lock type. The underlying buffer for each query component is updated with the appropriate record. If the query involves outer joins, some of the underlying buffers may be empty when this method returns. The NO-LOCK, SHARE-LOCK, EXCLUSIVE-LOCK and NO-WAIT parameters are not supported by conversion rules at the time of this writing.

lockType

Lock type to apply to records retrieved (overrides default lock type set for each query component).

Example:

def query q for book.

open query q preselect each book.
query q:get-first().

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper();
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
query0.first();

query0.close();

GET-LAST (Method)

referent:GET-LAST ( NO-LOCK | SHARE-LOCK [, NO-WAIT] | EXCLUSIVE-LOCK [, NO-WAIT] )

public void last()

public void last(LockType lockType)

(methods of com.goldencode.p2j.persist.P2JQuery)

Retrieve the last composite row of results for the query. The underlying buffer for each query component is updated with the appropriate record. If the query involves outer joins, some of the underlying buffers may be empty when this method returns. The NO-LOCK, SHARE-LOCK, EXCLUSIVE-LOCK and NO-WAIT parameters are not supported by conversion rules at the time of this writing.

lockType

Lock type to apply to records retrieved (overrides default lock type set for each query component).

Example:

def query q for book.

open query q preselect each book.
query q:get-last().

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper();
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
query0.last();

query0.close();

GET-NEXT (Method)

referent:GET-NEXT ( NO-LOCK | SHARE-LOCK [, NO-WAIT] | EXCLUSIVE-LOCK [, NO-WAIT] )

public void next()

public void next(LockType lockType)

(methods of com.goldencode.p2j.persist.P2JQuery)

Navigate to the next record which meets the query criteria and retrieve it into its record buffer. Use the default substitution parameters. Use the record most recently loaded into the backing buffer as the reference point when determining the next record to visit. If no record has yet been loaded into the buffer, retrieve the first record which meets the query criteria. If the query involves outer joins, some of the underlying buffers may be empty when this method returns. The NO-LOCK, SHARE-LOCK, EXCLUSIVE-LOCK and NO-WAIT parameters are not supported by conversion rules at the time of this writing.

lockType

Lock type to apply to records retrieved (overrides default lock type set for each query component).

Example:

def query q for book.

open query q preselect each book.
query q:get-next().

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper();
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
query0.next();

query0.close();

GET-PREVIOUS (Method)

referent:GET-PREVIOUS ( NO-LOCK | SHARE-LOCK [, NO-WAIT] | EXCLUSIVE-LOCK [, NO-WAIT] )

public void previous()

public void previous(LockType lockType)

(methods of com.goldencode.p2j.persist.P2JQuery)

Navigate to the previous record which meets the query criteria and retrieve it into its record buffer. Use the default substitution parameters. Use the record most recently loaded into the backing buffer as the reference point when determining the previous record to visit. If no record has yet been loaded into the buffer, retrieve the last record which meets the query criteria. If the query involves outer joins, some of the underlying buffers may be empty when this method returns. The NO-LOCK, SHARE-LOCK, EXCLUSIVE-LOCK and NO-WAIT parameters are not supported by conversion rules at the time of this writing.

lockType

Lock type to apply to records retrieved (overrides default lock type set for each query component).

Example:

def query q for book.

open query q preselect each book.
query q:get-previous().

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper();
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
query0.previous();

query0.close();

LAST (Function)

LAST           ( break-group )

public logical isLast()

(method of com.goldencode.p2j.persist.PresortQuery)

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the last iteration of that block.

In FWD these blocks are backed by queries which are iterated in conformity with block iterations. Therefore in FWD one should call the instance method of the presort query which backs the target block. This method returns TRUE if the current query result row is the last row.

break-group

Not used in FWD. In 4GL it allows to identify the target block.

Returns

In 4GL returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK

block is the last iteration of that block. In FWD returns TRUE if the current query result row is the last row.

Example:

def var counter as integer init 0.

for each book break by book.book-title:
  counter = counter + 1.
  if last(book.book-title) then message "Total books: " + counter.
end.

Converted example:

integer counter = new integer(0);
...
forEach("loopLabel0", new Block()
{
   PresortQuery query0 = null;

   FieldReference byExpr0 = new FieldReference(book, "bookTitle");

   public void init()
   {
      ...
      query0 = new PresortQuery(book, (String) null, null, "book.bookId asc");
      query0.enableBreakGroups();
      query0.setNonScrolling();
      query0.addSortCriterion(byExpr0);
    }

    public void body()
    {
       query0.next();
       counter.assign(plus(counter, 1));
       if ((query0.isLast()).booleanValue())
       {
          message(concat(new character("Total books: "), counter));
       }
    }
});

LAST-OF (Function)

LAST-OF ( break-group )

public logical isLastOfGroup( break-group )

(method of com.goldencode.p2j.persist.PresortQuery)

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the last iteration for a particular value of a break group.

In FWD these blocks are backed by queries which are iterated in conformity with block iterations. Therefore in FWD one should call the instance method of the presort query which backs the target block. This method returns TRUE if the current query result row is the last row within the specified break group.

break-group

In 4GL it is the name of a field or expression you name in the block header with the BREAK BY option that identifies the target break group. In FWD it is the reference to a Resolvable object that identifies the target break group and which was specified previously when invoking addSortCriterion on the presort query which backs the target block.

Returns

In 4GL this function returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the last iteration for a particular value of a break group. In FWD this function returns TRUE if the current query result row is the last row within the specified break group.

Example:

def var counter as integer init 0.

for each book break by book.publisher:
  counter = counter + 1.
  display book.publisher
          book.book-title with frame f1 10 down.
  if last-of(book.publisher) then do:
    message "Books by publisher '" + book.publisher + "': " + counter.
    counter = 0.
  end.
end.

Converted example:

integer counter = new integer(0);
...
forEach("loopLabel0", new Block()
{
   PresortQuery query0 = null;

   FieldReference byExpr0 = new FieldReference(book, "publisher");

   public void init()
   {
      ...
      query0 = new PresortQuery(book, (String) null, null, "book.publisher asc");
      query0.enableBreakGroups();
      query0.setNonScrolling();
      query0.addSortCriterion(byExpr0);
   }

   public void body()
   {
      query0.next();
      counter.assign(plus(counter, 1));

      FrameElement[] elementList0 = new FrameElement[]
      {
         new Element(new FieldReference(book, "publisher"), f1Frame.widgetPublisher()),
         new Element(new FieldReference(book, "bookTitle"), f1Frame.widgetBookTitle())
      };

      f1Frame.display(elementList0);

      if ((query0.isLastOfGroup(byExpr0)).booleanValue())
      {
         message(concat("Books by publisher '",
                        (character) new FieldReference(book, "publisher").getValue(),
                        "': ", counter));
         counter.assign(0);
      }
   }
});

LDBNAME (Function)

LDBNAME ( name | index | BUFFER dmo )

public static character ldbName(String name)

public static character ldbName(character name)

public static character ldbName(int index)

public static character ldbName(NumberType index)

public static character ldbName(Object dmo)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Returns the logical name of the database which corresponds the input parameter. Logical database name is the one that was specified into the CONNECT statement.

name

Logical name or alias of the target database.

index

The index of the target database among all connected databases. When the first database is connected, it receives the index 1, second database receives index 2 and so on. If a database has been disconnected, then indexes of the databases which were connected after it, will be decreased.

dmo

A data model object which belongs to the target database.

Returns

If a logical database name was specified: the same logical database name if such database is connected or unknown value if there is no such database.

If an alias name was specified: the logical name of the database which corresponds the given alias or unknown value if there is no such alias.

If an index was specified: the logical database name at the given index or the unknown value if there is no corresponding database.

If a data model object was specified: the logical name of the database which owns the given data model object.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message LDBNAME(1).
message LDBNAME("p2j_test").
message LDBNAME("some_alias").
message LDBNAME(BUFFER address).

Converted example:

Address address = RecordBuffer.define(Address.class, "p2j_test", "address");
...
ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.ldbName(new integer(1)));
message(ConnectionManager.ldbName(new character("p2j_test")));
message(ConnectionManager.ldbName(new character("some_alias")));
message(ConnectionManager.ldbName(address));

LOCKED (Function)

LOCKED ( dmo )

public static logical wasLocked(DataModelObject dmo)

public static boolean _wasLocked(DataModelObject@dmo@)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Returns a TRUE value if a record into a particular record buffer is not available to a prior FIND ... NO-WAIT statement because another user has locked a record.

dmo

The record buffer you want to check.

Returns

TRUE value if a record into a particular record buffer is not available to a prior FIND ... NO-WAIT statement because another user has locked a record.

Example:

find book where book-title = "Java Programming" exclusive-lock no-wait no-error.
if available(book) then message "The target book was found!".
else do:
  if locked(book) then message "The target book is locked by another user!".
  else message "Cannot find the target book!".
end.

Converted example:

Book book = RecordBuffer.define(Book.class,
"p2j_test", "book");
...
ErrorManager.silentErrorEnable();
new FindQuery(book, "upper(book.bookTitle) = 'JAVA PROGRAMMING'", null,
"book.bookId asc",           LockType.EXCLUSIVE_NO_WAIT).unique();
ErrorManager.silentErrorDisable();
if (RecordBuffer._isAvailable(book))
{
   message("The target book was found!");
}
else
{
   if (RecordBuffer._wasLocked(book))
   {
      message("The target book is locked by another user!");
   }
   else
   {
      message("Cannot find the target book!");
   }
}

NEW (Function)

NEW ( dmo )

public static logical isNew(DataModelObject dmo)

public static boolean _isNew(DataModelObject@dmo@)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Checks a record buffer and returns a TRUE value if the record in that buffer is newly created. If the record was read from the database, a FALSE value is returned.

dmo

The record buffer you want to check.

Returns

TRUE value if the record in the buffer is newly created. If the record was read from the database, a FALSE value is returned.

Example:

create book.
assign book.book-id = 199
       book.book-title = "The book" 
       book.isbn = "978-3-16-148410-0".
message new(book).                       /* displays “yes” */

find first book.
message new(book).                       /* displays “no” */

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
...
RecordBuffer.create(book);
RecordBuffer.startBatch();
book.setBookId(new integer(199));
book.setBookTitle(new character("The book"));
book.setIsbn(new character("978-3-16-148410-0"));
RecordBuffer.endBatch();
message(RecordBuffer.isNew(book));                       /* displays “yes” */

new FindQuery(book, (String) null, null, "book.bookId asc").first();
message(RecordBuffer.isNew(book));                       /* displays “no” */

NEXT-VALUE (Function)

NEXT-VALUE(sequence [, database])

public static int64 nextValue(String seqName, String@database@)

public static int64 nextValue(character seqName, String@database@)

public static int64 nextValue(String seqName, character@database@)

public static int64 nextValue(character seqName, character@database@)

(methods of com.goldencode.p2j.persist.SequenceManager)

Returns the next INT64 value of a sequence, incremented by the positive or negative value defined in the specified database.

If sequence is a cycling sequence, and the NEXT-VALUE function increments the sequence beyond its upper limit (for positive increments) or decrements the sequence beyond its lower limit (for negative increments), the function sets and returns the initial value defined for the sequence.

If sequence is a terminating sequence, and the NEXT-VALUE function attempts to increment the sequence beyond its upper limit (for positive increments) or decrement the sequence beyond its lower limit (for negative increments), the function returns the Unknown value (?) and leaves the current sequence value unchanged. Once a sequence terminates, NEXT-VALUE continues to return the Unknown value (?) for the specified sequence until it is reset to a new value with the CURRENT-VALUE statement, or its definition is changed to a cycling sequence. After changing the sequence definition to cycle, the first use of NEXT-VALUE for the sequence sets and returns its initial value.

sequence

An identifier that specifies the name of a sequence defined in the Data Dictionary.

database

An identifier that specifies the logical name of the database in which the sequence is defined. The database must be connected. You can omit this parameter if the sequence name is unambiguous. If a sequence with this name exists in more than one connected database, then you must specify database.

Returns:

The next INT64 value of a sequence, incremented by the positive or negative value defined in the specified database.

Example:

DISPLAY NEXT-VALUE(my-seq-1) NEXT-VALUE(my-seq-1, p2j_test).

Converted example:

FrameElement[] elementList1 = new FrameElement[]
{

   new Element(SequenceManager.nextValue("my-seq-1"), frame0.widgetExpr1())
   new Element(SequenceManager.nextValue("my-seq-1", "p2j_test"), frame0.widgetExpr2())
};

frame0.display(elementList1);

NUM-ALIASES (Function)

NUM-ALIASES ( )

public static integer numAliases()

(method of com.goldencode.p2j.persist.ConnectionManager)

Get the number of aliases currently defined in this context.

Returns

Number of aliases in this context.

Example:

message "Number of defined aliases:" string(num-aliases).

Converted example:

message(new Object[]
{
    "Number of defined aliases:",
    valueOf(ConnectionManager.numAliases())
});

NUM-BUFFERS (Attribute)

referent:NUM-BUFFERS

public int getTableCount()

(method of com.goldencode.p2j.persist.P2JQuery)

Get the number of tables joined by this query.

Returns

Number of tables joined by this query.

Example:

def query q for book.

open query q preselect each book.
message string(query q:num-buffers).

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper();
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
message(valueOf(query0.getTableCount()));

query0.close();

NUM-DBS (Function)

NUM-DBS ( )

public static integer numDbs()

(method of com.goldencode.p2j.persist.ConnectionManager)

Get the number of databases currently connected in this context.

Returns

Number of logical connections in this context.

Example:

message "Number of connected databases:" string(num-dbs).

Converted example:

message(new Object[]
{
    "Number of connected databases:",
    valueOf(ConnectionManager.numDBs())
});

NUM-RESULTS (Function)

NUM-RESULTS ( query-name )

public integer size()

(method of com.goldencode.p2j.persist.P2JQuery)

Get the current size of the cached results list. However, since this cache is built progressively as the query is scrolled, repositioned, and naturally navigated, this does not necessarily represent the full count of results which may satisfy the query.

query-name

A character expression that evaluates to the name of a open, scrolling query.

Returns

Current results list size or unknown value if the query is not open.

Example:

def query q for book scrolling.
open query q preselect each book.

get first q.
message "Number of read records:" string(num-results("q")).

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper(true);
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
query0.first();
message(new Object[]
{
    "Number of read records:",
    valueOf(query0.size())
});

query0.close();

PDBNAME (Function)

PDBNAME ( name | index )

public static character pdbName(NumberType index)

public static character pdbName(int index)

public static character pdbName(character name)

public static character pdbName(String name)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Returns the physical name of the database which corresponds the input parameter. In 4GL physical name is database filename. In FWD physical name is specified into p2j.cfg.xml into cfg/schema/namespace/name attribute.

name

Logical name or alias of the target database.

index

The index of the target database among all connected databases. When the first database is connected, it receives the index 1, second database receives index 2 and so on. If a database has been disconnected, then indexes of the databases which were connected after it, will be decreased.

Returns

If a logical database name was specified: the physical name of the database which corresponds the given logical name or unknown value if there is no such logical name.

If an alias name was specified: the physical name of the database which corresponds the given alias or unknown value if there is no such alias.

If an index was specified: the physical database name at the given index or the unknown value if there is no corresponding database.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message PDBNAME(1).
message PDBNAME("p2j_test").
message PDBNAME("some_alias").

Converted example:

ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.pdbName(new integer(1)));
message(ConnectionManager.pdbName(new character("p2j_test")));
message(ConnectionManager.pdbName(new character("some_alias")));

QUERY-OFF-END (Attribute and Function)

referent:QUERY-OFF-END

QUERY-OFF-END ( query-name )

public logical isOffEnd()

(methods of com.goldencode.p2j.persist.P2JQuery)

Indicate whether the cursor has run off one or the other end of the associated query's list of available results. If TRUE, this indicates that the query cannot produce any more results in the current scroll direction. Can only be used for scrolling queries.

When used as a function, query-name is a character expression which evaluates to an open, scrollable query.

Returns

TRUE if the cursor is off either end of its query's results list.

Example:

def query q for book scrolling.

open query q preselect each book.
message string(query q:query-off-end). /* attribute */
message string(query-off-end(“q”)). /* function */

close query q.

Converted example:

Book book = RecordBuffer.define(Book.class, "p2j_test", "book");
final QueryWrapper query0 = new QueryWrapper(true);
...
RecordBuffer.openScope(book);
query0.assign(new PreselectQuery(book, (String) null, null, "book.bookId asc"));

query0.open();
message(valueOf(query0.isOffEnd())); /* attribute */
message(valueOf(query0.isOffEnd())); /* function */

query0.close();

RECID (Function)

RECID ( dmo )

public static recid recordID(DataModelObject dmo)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Returns the unique identifier of the database record currently associated with the specified record buffer. This identifier has the data type RECID (four-byte integral value). In FWD this identifier matches the primary key (SQL) of the record. In FWD, primary keys are eight-byte integral values, so if a particular primary key is larger than the maximum four-byte value supported by the RECID data type, then this method raises an error.

dmo

The record buffer you want to check.

Returns

The unique identifier of the database record currently associated with the specified record buffer.

Example:

def var rid as recid.
def var response as logical.

find next book no-lock.
rid = recid(book).

message "Update book title '" + book.book-title + "'?" update response.

if response then do:
  find book where recid(book) = rid exclusive-lock. /* A record retrieved with NO-LOCK cannot be
                                                       updated, upgrading to EXCLUSIVE-LOCK. */
  update book.book-title.
end.

Converted example:

recid rid = new recid();
...
new FindQuery(book, (String) null, null, "book.bookId asc",
LockType.NONE).next();
rid.assign(RecordBuffer.recordID(book));

message(concat("Update book title '", (character) new
FieldReference(book, "bookTitle").getValue(),
        new character("'?")), false, new AccessorWrapper(response));

if ((response).booleanValue())
{
   new FindQuery(book, "book.id = ?", null, "book.bookId asc", new
Object[]
   {
      rid                                     /* A record retrieved with
 NO-LOCK cannot be

   }, LockType.EXCLUSIVE).unique();              updated, upgrading to
EXCLUSIVE-LOCK. */

   FrameElement[] elementList0 = new FrameElement[]
   {
      new Element(new FieldReference(book, "bookTitle"),
frame0.widgetBookTitle())
   };

   frame0.update(elementList0);
}

ROWID (Function)

ROWID ( dmo )

public static rowid rowID(DataModelObject dmo)

(methods of com.goldencode.p2j.persist.RecordBuffer)

Returns the unique identifier of the database record currently associated with the specified record buffer. This identifier has the data type ROWID (eight-byte integral value). In FWD this identifier matches the primary key (SQL) of the record.

dmo

The record buffer you want to check.

Returns

The unique identifier of the database record currently associated with the specified record buffer.

Example:

def var rid as rowid.
def var response as logical.

find next book no-lock.
rid = rowid(book).

message "Update book title '" + book.book-title + "'?" update response.

if response then do:
  find book where rowid(book) = rid exclusive-lock. /* A record retrieved with NO-LOCK cannot be
                                                       updated, upgrading to EXCLUSIVE-LOCK. */
  update book.book-title.
end.

Converted example:

rowid rid = new rowid();
...
new FindQuery(book, (String) null, null, "book.bookId asc", LockType.NONE).next();
rid.assign(RecordBuffer.rowID(book));

message(concat("Update book title '", (character) new FieldReference(book, "bookTitle").getValue(),
        new character("'?")), false, new AccessorWrapper(response));

if ((response).booleanValue())
{
   new FindQuery(book, "book.id = ?", null, "book.bookId asc", new Object[]
   {
      rid                                     /* A record retrieved with NO-LOCK cannot be */
   }, LockType.EXCLUSIVE).unique();           /* updated, upgrading to EXCLUSIVE-LOCK. */

   FrameElement[] elementList0 = new FrameElement[]
   {
      new Element(new FieldReference(book, "bookTitle"), frame0.widgetBookTitle())
   };

   frame0.update(elementList0);
}

SDBNAME (Function)

SDBNAME ( name | index )

public static character sdbName(NumberType index)

public static character sdbName(int index)

public static character sdbName(character name)

public static character sdbName(String name)

(methods of com.goldencode.p2j.persist.ConnectionManager)

Legacy function.

In 4GL if the parameter resolves to a currently connected non-Progress database then this function returns the logical name of the schema holder database containing the non-Progress schema. This functionality is not supported by FWD.

If the parameter resolves to a currently connected Progress database, this function returns the logical name of this database, i.e. acts as LDBNAME function. This functionality is supported by FWD.

name

Logical name or alias of the target database.

index

The index of the target database among all connected databases. When the first database is connected, it receives the index 1, second database receives index 2 and so on. If a database has been disconnected, then indexes of the databases which were connected after it, will be decreased.

Returns

If a logical database name was specified: the same logical database name if such database is connected or unknown value if there is no such database.

If an alias name was specified: the logical name of the database which corresponds the given alias or unknown value if there is no such alias.

If an index was specified: the logical database name at the given index or the unknown value if there is no corresponding database.

Example:

CREATE ALIAS some_alias FOR DATABASE p2j_test.
message SDBNAME(1).
message SDBNAME("p2j_test").
message SDBNAME("some_alias").

Converted example:

ConnectionManager.createAlias("some_alias", "p2j_test");
message(ConnectionManager.sdbName(new integer(1)));
message(ConnectionManager.sdbName(new character("p2j_test")));
message(ConnectionManager.sdbName(new character("some_alias")));

TO-ROWID (Function)

TO-ROWID ( rowid-string )

public rowid(String val)

public rowid(character val)

(constructors of com.goldencode.p2j.util.rowid)

Converts a string representation of a ROWID to a valid ROWID value.

When represented as strings, ROWID values are a variable sequence of hexadecimal digits prefixed by “0x”. Up to 16 lowercase hex-digits (characters from 0 through 9 and a through f) can be used for the 64-bit representation of a ROWID value. The length of the string must be even.

If the function cannot parse the input string an unknown value is returned.

val

A string representation of ROWID value as java.lang.String or com.goldencode.p2j.util.character.

Returns

If the parsing of the string is successful, an object holding the original value is created.

If an error occurs during parsing, the unknown ROWID object is returned.

Example:

DEFINE VARIABLE v-rowid AS ROWID NO-UNDO.
DEFINE VARIABLE ch-rowid AS CHARACTER INIT "0x0011aabb"  NO-UNDO.
v-rowid = TO-ROWID(ch-rowid).

Converted example:

rowid vRowid = new rowid();
character chRowid = new character("0x0011aabb");
vRowid.assign(new rowid(chRowid));

© 2004-2017 Golden Code Development Corporation. ALL RIGHTS RESERVED.