Page tree

EWSelectFromTable

Executes a query against the specified table and returns record identifiers that match the specified criteria.

Syntax

long ids[] = ew.EWSelectFromTable(String sessionId, String
    tableName, String whereClause);

Usage

Use the EWSelectFromTable call to search for records in the specified table.

The SQL query supplied should only include the "where" clause from a construct similar to:

select primary-key-field-name from table-name where ...

Rules and Guidelines

When querying records, consider the following rules and guidelines:

  • The queries operate on the database level and should be written in terms of names visible in the Agiloft GUI in the Table wizard in the dbname column. Also see EWGetChoiceLineId for special handling of choice values.
  • This method never returns null. In the case where no records are found an empty array is returned.

    Special note on memory management: As WS integration implies pass-by-value semantics, the memory allocated for the resulting array will be released once the data is sent to the client and the server-side JVM's garbage collector considers it eligible for discarding.

  • If the client-side environment is one with a garbage collector, the memory used by client-side array will be cleared once the client-side garbage collector considers it eligible.
  • When the client environment uses explicit memory management, the client is responsible for freeing up the used memory explicitly.
  • It is possible to limit the number of records returned through means available to the underlying database used by your instance of Agiloft e.g. "limit 0,200" for MySQL will limit the number of the returned records to 200).
  • It is not possible currently to influence the sequence in which records are returned. They are returned in the effectively arbitrary default order returned by the underlying database.

Basic Steps for Selecting Records

  1. Compose the whereClause. Note: "prepared" statements are not supported, all parameters have to be passed inside the whereClause string.
  2. Perform the call.
  3. Handle results, specifically the situations where there are no elements, one element, or more than one element in the returned array.

Example Task

In MyKB knowledgebase, as user A, find all cases assigned to John Doe. 

The task is completed by performing the following steps:

  1. Log in to MyKB with "A" and "password", English as the local language.
  2. Search for cases assigned to John Doe.
  3. Log out.

Sample Code - Java

You can generate a sample Web Services code for any table by selecting Setup > Tables > (Edit Table) > API > Download Sample.

 public long[] select() throws Exception {
    EWServiceAPI binding = new EWServiceAPIServiceLocator().getDemo();
    try {
    String sessionId = binding.EWLogin("MyKB", "A", "password", "en");
    long[] ids = binding.EWSelectFromTable(sessionId, "case",
    "assignee='John Doe'");
    return ids;
    } finally {
    binding.EWLogout(sessionId);
    }
    }

Arguments

Name

Type

Description

sessionId

String

Session token.

tableName

String

The name of the table where the query has to be performed.

where

string

The whereClause of the SQL select construct.

Response

The identifiers of the records that match the specified criteria.

Faults

EWSessionException - client not logged in or the session has expired; client should re-login. 

EWPermissionException - user used to create the session lacks the sufficient privileges to run the query. 

EWWrongDataException - client has supplied the wrong data. 

EWOperationException - the operation has been blocked by an Agiloft function, for example a table-level lock. 

EWIntegrityException - the specified table cannot be found or its primary key cannot be identified. 

EWUnexpectedException - an unexpected exception has happened; user should report this for investigation.