1 DB

Class Ax.db


Class that represents a connection to a database.

Method Summary

Modifier and Type
Method
Description
static Object 
NVL(Object expr1, Object expr2)
Implements the NVL function.
static Ax.sql.QBE 
QBE()
Returns a QBE (query by example).
static void 
static Object 
apply(Ax.text.String name,Object[] args)
Called to invoke another script from connection.
static void 
Initiates a transaction within the connection.
static Object 
call(Ax.text.String name,Object[] args)
Called to invoke another script from connection.
static void 
Force a refresh of tables metadata cache.
static void 
Force a refresh of all tables metadata
static void 
clearTableMetaData(Ax.text.String tabname)
Force a refresh of table metadata cache.
static Ax.db 
cloned()
An alternative connection to be used to handle dual transactions.
static void 
It makes that all the changes made after the previous commit/rollback be permanent and sets free all the locks in the database generated by this object.
static TableCopyEvent 
copy(Ax.db other,Ax.text.String tableName,Consumer<TableCopyOptions> options)
Copies a table from the connection db to another db.
static JSDBCopy 
dbcopy(Ax.db dst)
Creates a DBCopy instance for this database to target dst database.
static JSSQLCA 
delete(Ax.text.String tableName,Map<StringObject> args)
Deletes the rows from the specified table with the same column values as defined by args.
static JSSQLCA 
delete(Ax.text.String tableName, Map<StringObject> args, Ax.text.String where)
Deletes the rows from the specified table with the same column values as defined by args, and that fulfill the where clause conditions.
static JSSQLCA 
delete(Ax.text.String tableName,Ax.text.String where)
Deletes the rows from the specified table that fulfill the where clause conditions.
static void 
When a JSResultSet is manually closed by application, remove it from close list.
static void 
Disables transactions on physical connection.
static void 
Enables transactions on physical connection.
static Ax.text.String 
escape(Ax.text.String token)
It prevents sql injection when embedding a variable content directly inside SQL Statement.
static JSSQLCA 
execute(Ax.text.String sql, Object[] args)
Execute an SQL statement that may return a ResultSet or not depending statement type.
static JSResultSet 
executeCachedQuery(Ax.text.String sql)
Executes a query and caches the ResultSet.
static JSResultSet 
executeCachedQuery(Ax.text.String sql, Object[] args)
static JSResultSet 
executeFunction(Ax.text.String name,Object[] args)
Executes the specified native SQL function.
static JSResultSet 
executeFunction(Ax.text.String name, Function<IntegerString> columnNameMap, Object[] args)
Executes the specified native SQL function.
static Map 
Executes the specified native SQL function.
static Object 
executeGet(Ax.text.String sql, Object[] args)
Executes a SQL query and returns a single value, when possible, converted to native javascript type.
static double 
executeGetDouble(Ax.text.String sql,Object[] args)
Executes the query and returns a double value, when possible.
static int 
executeGetInt(Ax.text.String sql, Object[] args)
Executes the query and returns an integer value, when possible.
static long 
executeGetLong(Ax.text.String sql,Object[] args)
Executes the query and returns a long value, when possible.
static JSResultSet 
executeGlobalCachedQuery(Ax.text.String sql, Object[] args)
static JSResultSet 
executeGlobalCachedQuery(Ax.text.String sql,int ttl,Object[] args)
static JSResultSet 
executeLocalCachedQuery(Ax.text.String sql)
Executes a query and caches the ResultSet.
static JSResultSet 
executeLocalCachedQuery(Ax.text.String sql,Object[] args)
static JSResultSet 
executePreparedQuery(Ax.text.String stmt, Map<StringObject> args)
static JSResultSet 
executeProcedure(Ax.text.String name,Object[] args)
Executes the specified native SQL procedure.
static JSResultSet 
executeProcedure(Ax.text.String name, Function<IntegerString> columnNameMap, Object[] args)
Executes the specified native SQL procedure.
static JSResultSet 
executeQuery(Ax.text.String sql,Object[] args)
Accepts a direct SQL or even XSQL return Ax.
static JSResultSet 
executeQueryForUpdate(Ax.text.String sql)
static JSResultSet 
executeScriptOrQuery(Ax.text.String sql)
Executes a query or a XSQL-Script.
static JSResultSet 
executeScrollableQuery(Ax.text.String sql, Object[] args)
Returns a scrollable ResultSet.
static boolean 
existsFunction(Ax.text.String functionName)
Checks if a function exists in the database.
static boolean 
existsPhysicalTable(Ax.text.String tableName)
Checks if a table exists in the database and is a physical table.
static boolean 
existsProcedure(Ax.text.String procedureName)
Checks if a procedure exists in the database.
static boolean 
existsTable(Ax.text.String tableName)
Checks if a table synonym or view exists in the database.
static boolean 
existsTempTable(Ax.text.String tableName)
Checks if a table exists in the database and is a temporary table.
static Ax.text.String 
fn(Ax.text.String fname)
Returns the function name according specific database agent.
static boolean 
static Ax.text.String 
getBasicTextSearch(Ax.text.String colname, Ax.text.String text)
Returns the basic text search statement for the engine.
static Ax.text.String 
getBestTextSearch(Ax.text.String tabname,Ax.text.String colname,Ax.text.String text,boolean fuzzy)
Returns the best text search possible for the column.
static Ax.text.String 
Returns the database name (logical code).
static Ax.db 
getConnection(Ax.text.String server,Ax.text.String name)
Gets a connection by db name from provider on a given server an database name.
static Ax.text.String 
Returns a string with the connection database and server names with the format: db@srv .
static Ax.text.String 
static Ax.text.String 
getDatabaseEncoding(boolean convert2JavaEncoding)
Returns the database encoding.
static JDBCDriver 
Returns the database driver.
static Ax.text.String 
getFuzzyTextSearch(Ax.text.String colname, Ax.text.String text)
Returns the fuzzy (approximate) text search statement.
static Ax.text.String 
Returns the database logical code.
static Ax.text.String 
Returns the logical user executing the connection.
Gets the database metadata wrapper.
getMetaData(boolean refresh)
Returns the database metadata wrapper and forces a refresh of tables metadata cache if refresh is true.
static Ax.text.String 
Returns the database name.
static int 
Returns the context open ResultSets.
static Ax.text.String 
Returns the database logical code.
static Ax.text.String 
Returns the physical user executing the connection.
static List 
Gets the list of active progress (useful for debug).
static Ax.text.String 
Returns the content of the debug file.
static Ax.text.String 
Returns the server code.
static int 
Gets the id of the session.
static Ax.db 
Creates a new JSConnection instance sharing the original connection.
Gets the standard error of the connection's monitoring console.
Gets the standard output of the connection's monitoring console.
static Ax.text.String 
getTempTableName(Ax.text.String pattern)
Creates a temporary table for the duration of the script execution and returns its name.
static Ax.text.String 
Get user from http request (till we do no have a better way).
static boolean 
Checks if there is any initialization error.
static boolean 
Checks if database has text search extensions.
static JSSQLCA 
insert(Ax.text.String tableName, Map<StringObject> args)
Inserts a map(JSON) into a table.
static int 
insert(Ax.text.String tableName,List<Map> list)
Inserts an array of maps(JSON) into a table [{colname: value, .
static JSBatchInsert 
insertBatch(Ax.text.String tableName)
Returns a JSBatchInsert to allow Javascript operate in batch inserts.
static JSSQLCA 
insertOrUpdate(Ax.text.String tableName,Map<StringObject> rowData)
Inserts a JSON object.
static JSSQLCA 
insertOrUpdate(Ax.text.String tableName, Map<StringObject> dataMap, Map<StringObject> keysMap)
Try insert data, if already exists row with same values in the key columns, then update.
static boolean 
static boolean 
Returns true or false if there is a open transaction.
static boolean 
Checks if the conection is read only.
static void 
lockTable(Ax.text.String tableName)
Locks the specified table in th default mode.
static void 
lockTable(Ax.text.String tableName,Ax.text.String mode)
Locks the table in the spedified mode.
moveTableRow(Ax.text.String tabname, Ax.text.String colname, String[] groupColumns, int from, int to)
A move row operation.
moveTableRow(Ax.text.String tabname,Ax.text.String colname,int from,int to)
A move row operation.
static Optional 
nullable(T value)
Wrap a nullable value in an Optional.
static Ax.db 
of(Ax.text.String name)
static Ax.db 
of(Ax.text.String name, boolean nonPooledConnection)
Gets a connection by db name from provider on same "connection" server.
static Ax.db 
of(Ax.text.String server,Ax.text.String name)
static Ax.db 
of(Ax.text.String server, Ax.text.String name, boolean nonPooledConnection)
Gets a connection by db name from provider on a given server an database name.
static Ax.db 
ofNonPooled(Ax.text.String name)
static Ax.db 
ofNonPooled(Ax.text.String server, Ax.text.String name)
static void 
This method is called at JSScriptRunner end.
static void 
Ends a failed transaction.
static void 
setConnection(Ax.db conn)
Redirect current Ax connection to the new connection specified.
static void 
setDebug(boolean debug)
Notify database connection debug is enabled, this will cause some classes using connection may enable debug log.
static void 
setPreparedStatementCache(boolean mode)
Enable or disable the use of prepared statements cache.
static void 
Sets the cache size.
static Ax.text.String 
setSPLDebug(boolean on)
Creates a SPL procedure named set_debug on current database.
Gets the statistics at this moment.
static long 
submit(@org.eclipse.jdt.annotation.NonNull java.lang.String sql,Consumer<JDBCPoolTask> consumer)
Runs an async task
static boolean 
Checks if the connection supports transactions.
static Ax.text.String 
Converts a Date (javascript or java) to it's corresponding database date function.
static Ax.text.String 
Converts a Date (javascript or java) to it's corresponding database date function.
static Ax.text.String 
Returns a string with the connection database and server names with the format: db@srv .
static JSSQLCA 
update(Ax.text.String tableName, Map<StringObject> rowData)
Updates a row using automatic primary key detection and NO where condition rowData is a JSON with the format {colname: value, .
static JSSQLCA 
update(Ax.text.String tableName,Map<StringObject> rowData,Ax.text.String condition)
Updates a row using a where condition and NO primary key:
static JSSQLCA 
update(Ax.text.String tableName, Map<StringObject> dataMap, Map<StringObject> keysMap)
Updates a row.
static JSSQLCA 
update(Ax.text.String tableName,Map<StringObject> dataMap,Map<StringObject> keysMap,Ax.text.String condition)
Updates a row.
static JSBatchUpdate 
updateBatch(Ax.text.String tableName)
Creates an update batch object to update table passed as parameter.
static JSSQLCA 
updateOrInsert(Ax.text.String tableName,Map<StringObject> rowData)
Insert or Updates row provided in columnMap.
static JSSQLCA 
updateOrInsert(Ax.text.String tableName, Map<StringObject> dataMap, Map<StringObject> keysMap)
Try insert data, if it fails ( eg: tried to duplicate a pk), then update The keysMap and dataMap in JS are a JSON of the form {colname: value, .

Method Detail

Ax.db.NVL

static object Ax.db.NVL(
	object expr1,
	object expr2
)
Info:
Implements the NVL function. If expr1 is null, expr2's value is applied.
Parameters:
expr1 - expression espression to return if it is not null
expr2 - expression to return in case expr1 is null
Returns:
object

Example
Copy
var char1 = null;
   //var char1 = 'a';
   return Ax.db.executeQuery(`
       SELECT ${Ax.db.NVL(char1, 'hello')}
         FROM systables
        WHERE tabid = 1
	`);

Ax.db.QBE

static object Ax.db.QBE()
Info:
Returns a QBE (query by example).
Returns:
object

Ax.db.addResultSet

static null Ax.db.addResultSet(
	resultset rs
)
Parameters:
rs - 
Returns:
null

Ax.db.apply

static object Ax.db.apply(
	string name,
	object[] args
)
Info:
Called to invoke another script from connection.
Parameters:
name - name of the script to call
args - array with the script parameters
Returns:
object

Example
Copy
Ax.db.apply('my_script_name', [arg1, arg2...]) //or
 Ax.db.apply('my_script_name', arguments)

Ax.db.beginWork

static null Ax.db.beginWork()
Info:
Initiates a transaction within the connection. If a transaction is already openned, this command closes previous transaction executing a "commit work" and opens a new database transaction.
Returns:
null

Ax.db.call

static object Ax.db.call(
	string name,
	object[] args
)
Info:
Called to invoke another script from connection.
Parameters:
name - name of the script to call
args - the script parameters
Returns:
object

Example
Copy
Ax.db.call('my_script_name', arg1, arg2...)

Ax.db.clearDatabaseMetaData

static null Ax.db.clearDatabaseMetaData()
Info:
Force a refresh of tables metadata cache. It may be useful when we are changing a table schema on a table already used by database. For example during TableInsert or TableUpdate operations metadata is always cached.
Returns:
null

Ax.db.clearTableMetaData

static null Ax.db.clearTableMetaData()
Info:
Force a refresh of all tables metadata
Returns:
null

Ax.db.clearTableMetaData

static null Ax.db.clearTableMetaData(
	string tabname
)
Info:
Force a refresh of table metadata cache. It may be useful when we are changing a table schema on a table already used by database. For example during TableInsert or TableUpdate operations metadata is always cached.
Parameters:
tabname - table to clear metadata on
Returns:
null

Ax.db.cloned

static object Ax.db.cloned()
Info:
An alternative connection to be used to handle dual transactions. The case: Use alternate connection to block a specific table (A) Use general connection to perform multiple transactions on other table (B) while we keep a lock on (A). Finally we will unlock A either by an implicit commit or by the automatic release of connection on finalization. Same as of(name)
Returns:
object

Ax.db.commitWork

static null Ax.db.commitWork()
Info:
It makes that all the changes made after the previous commit/rollback be permanent and sets free all the locks in the database generated by this object.
Returns:
null

Ax.db.copy

static object Ax.db.copy(
	object other,
	string tableName,
	object options
)
Info:
Copies a table from the connection db to another db.
Parameters:
other - destination connection
tableName - name of the table to copy
options - copying options
Returns:
object

Ax.db.dbcopy

static object Ax.db.dbcopy(
	object dst
)
Info:
Creates a DBCopy instance for this database to target dst database.
Parameters:
dst - destination database
Returns:
object

Ax.db.delete

static object Ax.db.delete(
	string tableName,
	object args
)
Info:
Deletes the rows from the specified table with the same column values as defined by args. args is a JSON with the format: {colname: value, ...} If a row has the same values as defined in args, it will be deleted.
Parameters:
tableName - name of the table to do the delete
args - map(JSON) with the columns and values to check for deletion
Returns:
object

Ax.db.delete

static object Ax.db.delete(
	string tableName,
	object args,
	string where
)
Info:
Deletes the rows from the specified table with the same column values as defined by args, and that fulfill the where clause conditions. args is a JSON with the format: {colname: value, ...} If a row has the same values as defined in args (and fulfills where clause conditions), it will be deleted.
Parameters:
tableName - name of the table to do the delete
args - map(JSON) with the columns and values to check for deletion
where - sql where clause for deletion
Returns:
object

Ax.db.delete

static object Ax.db.delete(
	string tableName,
	string where
)
Info:
Deletes the rows from the specified table that fulfill the where clause conditions.
Parameters:
tableName - name of the table to do the delete
where - sql where clause for deletion
Returns:
object

Ax.db.deregisterResultSet

static null Ax.db.deregisterResultSet(
	resultset rs
)
Info:
When a JSResultSet is manually closed by application, remove it from close list. It also happens when JSResultSet is returned to Javascript caller. In that case we de-register it to avoid it's being closed before connection release. Called from JSResultSet.
Parameters:
rs - ResultSet to deregister
Returns:
null

Ax.db.disableTransactions

static null Ax.db.disableTransactions()
Info:
Disables transactions on physical connection. In case of using a physical connection, obtained from de JSConnection, but not the JSConnection itself. It is the case of a Javascript invoking a Report execution.
Returns:
null

Ax.db.enableTransactions

static null Ax.db.enableTransactions()
Info:
Enables transactions on physical connection.
Returns:
null

Ax.db.escape

static string Ax.db.escape(
	string token
)
Info:
It prevents sql injection when embedding a variable content directly inside SQL Statement.
Parameters:
token - variable to embed
Returns:
string

Ax.db.execute

static object Ax.db.execute(
	string sql,
	object[] args
)
Info:
Execute an SQL statement that may return a ResultSet or not depending statement type.
Parameters:
sql - SQL statementto execute
args - 
Returns:
object

Ax.db.executeCachedQuery

static resultset Ax.db.executeCachedQuery(
	string sql
)
Info:
Executes a query and caches the ResultSet.
Parameters:
sql - query to execute
Returns:
resultset

Ax.db.executeCachedQuery

static resultset Ax.db.executeCachedQuery(
	string sql,
	object[] args
)
Parameters:
sql - query to execute
args - query arguments
Returns:
resultset

Ax.db.executeFunction

static resultset Ax.db.executeFunction(
	string name,
	object[] args
)
Info:
Executes the specified native SQL function.
Parameters:
name - name of the function
args - function arguments
Returns:
resultset

Example
Copy
return Ax.db.executeFunction('informix_function1', 'systables');

Ax.db.executeFunction

static resultset Ax.db.executeFunction(
	string name,
	object columnNameMap,
	object[] args
)
Info:
Executes the specified native SQL function. Applies to Informix function call style -
Parameters:
name - name of the function
columnNameMap - Function to specify the name of the columns of the Resultset
args - function arguments
Returns:
resultset

Example
Copy
return Ax.db.executeFunction('informix_function1', columnIndex => {
   switch (columnIndex) {
 		case 1: return "tabid";
  	case 2: return "nrows";
  	default: return c + columnIndex;
   }
 }, 'systables');

Ax.db.executeFunction

static object Ax.db.executeFunction(
	string name,
	object options
)
Info:
Executes the specified native SQL function. Applies to ORACLE function call style -
Parameters:
name - name of the function
options - function configuration options
Returns:
object

Example
Copy
return Ax.db.executeFunction("informix_function_registerOut", config => {
		config.setString(1, "systables");
 		config.registerOutParameter(1, java.sql.JDBCType.INTEGER, "tabid");
 		config.registerOutParameter(2, java.sql.JDBCType.INTEGER, "nrows");
  });

Ax.db.executeGet

static object Ax.db.executeGet(
	string sql,
	object[] args
)
Info:
Executes a SQL query and returns a single value, when possible, converted to native javascript type. For example, Object[], List, Map and java.util.Date are transformed. Notice that java.sql.Date is keep of original type to prevent GMT offset date change.
Parameters:
sql - SQL query to execute
args - query arguments
Returns:
object

Ax.db.executeGetDouble

static double Ax.db.executeGetDouble(
	string sql,
	object[] args
)
Info:
Executes the query and returns a double value, when possible.
Parameters:
sql - SQL query to execute
args - query arguments
Returns:
double

Ax.db.executeGetInt

static smallint Ax.db.executeGetInt(
	string sql,
	object[] args
)
Info:
Executes the query and returns an integer value, when possible.
Parameters:
sql - SQL query to execute
args - query arguments
Returns:
smallint

Ax.db.executeGetLong

static long Ax.db.executeGetLong(
	string sql,
	object[] args
)
Info:
Executes the query and returns a long value, when possible.
Parameters:
sql - SQL query to execute
args - query arguments
Returns:
long

Ax.db.executeGlobalCachedQuery

static resultset Ax.db.executeGlobalCachedQuery(
	string sql,
	object[] args
)
Parameters:
sql - 
args - 
Returns:
resultset

Ax.db.executeGlobalCachedQuery

static resultset Ax.db.executeGlobalCachedQuery(
	string sql,
	smallint ttl,
	object[] args
)
Parameters:
sql - query to execute
ttl - time to live in seconds
args - query arguments
Returns:
resultset

Ax.db.executeLocalCachedQuery

static resultset Ax.db.executeLocalCachedQuery(
	string sql
)
Info:
Executes a query and caches the ResultSet.
Parameters:
sql - query to execute
Returns:
resultset

Ax.db.executeLocalCachedQuery

static resultset Ax.db.executeLocalCachedQuery(
	string sql,
	object[] args
)
Parameters:
sql - query to execute
args - query arguments
Returns:
resultset

Ax.db.executePreparedQuery

static resultset Ax.db.executePreparedQuery(
	string stmt,
	object args
)
Parameters:
stmt - 
args - 
Returns:
resultset

Ax.db.executeProcedure

static resultset Ax.db.executeProcedure(
	string name,
	object[] args
)
Info:
Executes the specified native SQL procedure.
Parameters:
name - name of the procedure
args - procedure arguments
Returns:
resultset

Ax.db.executeProcedure

static resultset Ax.db.executeProcedure(
	string name,
	object columnNameMap,
	object[] args
)
Info:
Executes the specified native SQL procedure. columnNameMap is used to set names for the columns of the returned ResultSet. Useful in case the ResultSet's column names are like "(expression)".
Parameters:
name - name of the procedure
columnNameMap - Function to specify the name of the columns of the Resultset
args - procedure arguments
Returns:
resultset

Ax.db.executeQuery

static resultset Ax.db.executeQuery(
	string sql,
	object[] args
)
Info:
Accepts a direct SQL or even XSQL return Ax.db.executeQuery("
Parameters:
sql - query to execute
args - query arguments
Returns:
resultset

Example
Copy
*
Example
Copy
systables

Ax.db.executeQueryForUpdate

static resultset Ax.db.executeQueryForUpdate(
	string sql
)
Parameters:
sql - 
Returns:
resultset

Ax.db.executeScriptOrQuery

static resultset Ax.db.executeScriptOrQuery(
	string sql
)
Info:
Executes a query or a XSQL-Script.
Parameters:
sql - query or call to a script
Returns:
resultset

Ax.db.executeScrollableQuery

static resultset Ax.db.executeScrollableQuery(
	string sql,
	object[] args
)
Info:
Returns a scrollable ResultSet. By default ResultSets are iterable only forwards. If it is scrollable, it does not have that restriction.
Parameters:
sql - query to execute
args - query arguments
Returns:
resultset

Ax.db.existsFunction

static boolean Ax.db.existsFunction(
	string functionName
)
Info:
Checks if a function exists in the database.
Parameters:
functionName - the name of the function to check
Returns:
boolean

Ax.db.existsPhysicalTable

static boolean Ax.db.existsPhysicalTable(
	string tableName
)
Info:
Checks if a table exists in the database and is a physical table. Temporary tables, views or synonyms will not be detected.
Parameters:
tableName - the name of the table to check
Returns:
boolean

Ax.db.existsProcedure

static boolean Ax.db.existsProcedure(
	string procedureName
)
Info:
Checks if a procedure exists in the database.
Parameters:
procedureName - the name of the procedure to check
Returns:
boolean

Ax.db.existsTable

static boolean Ax.db.existsTable(
	string tableName
)
Info:
Checks if a table synonym or view exists in the database. Temporary tables will not be detected.
Parameters:
tableName - the name of the table to check
Returns:
boolean

Ax.db.existsTempTable

static boolean Ax.db.existsTempTable(
	string tableName
)
Info:
Checks if a table exists in the database and is a temporary table.
Parameters:
tableName - the name of the table to check
Returns:
boolean

Ax.db.fn

static string Ax.db.fn(
	string fname
)
Info:
Returns the function name according specific database agent.
Parameters:
fname - the function name
Returns:
string

Example
Copy
return Ax.db.executeQuery(`
 		SELECT TRIM(tabname), ${Ax.db.fn("trim")}(tabname)
   	  FROM systables
 	     WHERE tabid = 1
 `);

Ax.db.getAutoCommit

static boolean Ax.db.getAutoCommit()
Returns:
boolean

Ax.db.getBasicTextSearch

static string Ax.db.getBasicTextSearch(
	string colname,
	string text
)
Info:
Returns the basic text search statement for the engine. It does not check if column has text search eanbled.
Parameters:
colname - the column to search on
text - the text to search
Returns:
string

Ax.db.getBestTextSearch

static string Ax.db.getBestTextSearch(
	string tabname,
	string colname,
	string text,
	boolean fuzzy
)
Info:
Returns the best text search possible for the column. This can be a specific text search statement if database has a text search module or a simple LIKE if no TS module is available. Probably the best option to get a LIKE or BASIC text search.
Parameters:
tabname - the table to search on
colname - the column of the table to search on
text - the text to search
fuzzy - 
Returns:
string

Ax.db.getCode

static string Ax.db.getCode()
Info:
Returns the database name (logical code). Same as getLogicalCode().
Returns:
string

Ax.db.getConnection

static object Ax.db.getConnection(
	string server,
	string name
)
Info:
Gets a connection by db name from provider on a given server an database name. Same as of(server, name).
Parameters:
server - name of the db to connect to
name - name of the server to connect to
Returns:
object

Ax.db.getDatabaseAtServer

static string Ax.db.getDatabaseAtServer()
Info:
Returns a string with the connection database and server names with the format: db@srv . Same as toString().
Returns:
string

Ax.db.getDatabaseEncoding

static string Ax.db.getDatabaseEncoding()
Returns:
string

Ax.db.getDatabaseEncoding

static string Ax.db.getDatabaseEncoding(
	boolean convert2JavaEncoding
)
Info:
Returns the database encoding. Typical Informix locales:
Parameters:
convert2JavaEncoding - 
Returns:
string

Example
Copy
dbs_collate		locale

	1	en_US.819		Latin 1, ISO 8859-1
	2	en_US.57372		UTF-8

Ax.db.getDriver

static object Ax.db.getDriver()
Info:
Returns the database driver. It's needed for dbexport model SQL.
Returns:
object

Example
Copy
new Ax.rs.Writer(rs).sql(options => {
 		options.setTableName("systables");
 		options.setDriver(Ax.db.getDriver());
 	});

Ax.db.getFuzzyTextSearch

static string Ax.db.getFuzzyTextSearch(
	string colname,
	string text
)
Info:
Returns the fuzzy (approximate) text search statement. It does not check if column has text search eanbled.
Parameters:
colname - the column to search on
text - the text to search
Returns:
string

Ax.db.getLogicalCode

static string Ax.db.getLogicalCode()
Info:
Returns the database logical code. Same as getName().
Returns:
string

Ax.db.getLogicalUser

static string Ax.db.getLogicalUser()
Info:
Returns the logical user executing the connection.
Returns:
string

Ax.db.getMetaData

static object Ax.db.getMetaData()
Info:
Gets the database metadata wrapper.
Returns:
object

Ax.db.getMetaData

static object Ax.db.getMetaData(
	boolean refresh
)
Info:
Returns the database metadata wrapper and forces a refresh of tables metadata cache if refresh is true.
Parameters:
refresh - true to clear metadata, false otherwise
Returns:
object

Ax.db.getName

static string Ax.db.getName()
Info:
Returns the database name.
Returns:
string

Ax.db.getOpenResultSets

static smallint Ax.db.getOpenResultSets()
Info:
Returns the context open ResultSets. It's useful for tests to ensure the number of open statements are as expected.
Returns:
smallint

Ax.db.getPhysicalCode

static string Ax.db.getPhysicalCode()
Info:
Returns the database logical code.
Returns:
string

Ax.db.getPhysicalUser

static string Ax.db.getPhysicalUser()
Info:
Returns the physical user executing the connection.
Returns:
string

Ax.db.getProgressMonitor

static array Ax.db.getProgressMonitor()
Info:
Gets the list of active progress (useful for debug).
Returns:
array

Ax.db.getSPLDebug

static string Ax.db.getSPLDebug()
Info:
Returns the content of the debug file.
Returns:
string

Ax.db.getServer

static string Ax.db.getServer()
Info:
Returns the server code.
Returns:
string

Ax.db.getSessionId

static smallint Ax.db.getSessionId()
Info:
Gets the id of the session.
Returns:
smallint

Ax.db.getSharedConnection

static object Ax.db.getSharedConnection()
Info:
Creates a new JSConnection instance sharing the original connection.
Returns:
object

Ax.db.getStderr

static object Ax.db.getStderr()
Info:
Gets the standard error of the connection's monitoring console.
Returns:
object

Ax.db.getStdout

static object Ax.db.getStdout()
Info:
Gets the standard output of the connection's monitoring console.
Returns:
object

Ax.db.getTempTableName

static string Ax.db.getTempTableName(
	string pattern
)
Info:
Creates a temporary table for the duration of the script execution and returns its name.
Parameters:
pattern - prefix of the temp table name
Returns:
string

Ax.db.getUser

static string Ax.db.getUser()
Info:
Get user from http request (till we do no have a better way).
Returns:
string

Ax.db.hasInitializationError

static boolean Ax.db.hasInitializationError()
Info:
Checks if there is any initialization error.
Returns:
boolean

Ax.db.hasTextSearch

static boolean Ax.db.hasTextSearch()
Info:
Checks if database has text search extensions.
Returns:
boolean

Ax.db.insert

static object Ax.db.insert(
	string tableName,
	object args
)
Info:
Inserts a map(JSON) into a table. {colname: value, ...}
Parameters:
tableName - name of the table to do the insert
args - map(JSON) with the insert data
Returns:
object

Ax.db.insert

static smallint Ax.db.insert(
	string tableName,
	array list
)
Info:
Inserts an array of maps(JSON) into a table [{colname: value, ...}, ...]
Parameters:
tableName - name of the table to do the insert
list - array of map(JSON) with the insert data
Returns:
smallint

Ax.db.insertBatch

static object Ax.db.insertBatch(
	string tableName
)
Info:
Returns a JSBatchInsert to allow Javascript operate in batch inserts.
Parameters:
tableName - table name whee the batch insert will be done
Returns:
object

Ax.db.insertOrUpdate

static object Ax.db.insertOrUpdate(
	string tableName,
	object rowData
)
Info:
Inserts a JSON object. If insert fails with duplicated row, an update is executed by auto discovery primary key from row data. rowData is a JSON with the format {'colname: value, ...}.
Parameters:
tableName - name of the table
rowData - data to insert / update
Returns:
object

Ax.db.insertOrUpdate

static object Ax.db.insertOrUpdate(
	string tableName,
	object dataMap,
	object keysMap
)
Info:
Try insert data, if already exists row with same values in the key columns, then update. dataMap and keysMap are JSON with the format {colname: value, ...}.
Parameters:
tableName - name of the table
dataMap - map(JSON) to do the insert/update
keysMap - key columns to check if insert or update
Returns:
object

Ax.db.isNonPooledConnection

static boolean Ax.db.isNonPooledConnection()
Returns:
boolean

Ax.db.isOnTransaction

static boolean Ax.db.isOnTransaction()
Info:
Returns true or false if there is a open transaction.
Returns:
boolean

Ax.db.isReadOnly

static boolean Ax.db.isReadOnly()
Info:
Checks if the conection is read only.
Returns:
boolean

Ax.db.lockTable

static null Ax.db.lockTable(
	string tableName
)
Info:
Locks the specified table in th default mode. AUTO LOCK TABLE table-Name (default mode) Notice that MYSQL and SQLServer are not standard and don't support SHARE|EXCLUSIVE modes.
Parameters:
tableName - name of the table to lock
Returns:
null

Ax.db.lockTable

static null Ax.db.lockTable(
	string tableName,
	string mode
)
Info:
Locks the table in the spedified mode. ANSI LOCK TABLE table-Name IN { SHARE | EXCLUSIVE } MODE
Parameters:
tableName - name of the table
mode - lock mode, share/exclusive
Returns:
null

Ax.db.moveTableRow

static object Ax.db.moveTableRow(
	string tabname,
	string colname,
	string[] groupColumns,
	smallint from,
	smallint to
)
Info:
A move row operation. Assuming that in the table the rows are ordered by sequence number, it moves the row from the 'from' position, to the 'to' position if the condition is satisfied.
Parameters:
tabname - table where the move is taking place
colname - sequence number column to use as from and to
groupColumns - the group columns
from - sequence number of the origin row
to - sequence number of the destination row
Returns:
object

Ax.db.moveTableRow

static object Ax.db.moveTableRow(
	string tabname,
	string colname,
	smallint from,
	smallint to
)
Info:
A move row operation. Assuming that in the table the rows are ordered by sequence number, it moves the row from the 'from' position, to the 'to' position if the condition is satisfied. Given the following example:
Parameters:
tabname - table where the move is taking place
colname - sequence number column to use as from and to
from - sequence number of the origin row
to - sequence number of the destination row
Returns:
object

Example
Copy
+------+----------+
	|seqno |fruit     |
	+------+----------+
	|     1|Banana    |
	|     2|Mango     |
 	|     3|Apple     |
	|     4|Carrot    |
	+------+----------+

	MOVE 2(Mango) - 3(Apple)
	+------+----------+
	|seqno |fruit     |
	+------+----------+
	|     1|Banana    |
	|     2|Apple     |
	|     3|Mango     |
	|     4|Carrot    |
	+------+----------+

Ax.db.nullable

static object Ax.db.nullable(
	object value
)
Info:
Wrap a nullable value in an Optional. Intented to use with varargs to avoid issues with graal whem vararg is a single null value
Parameters:
value - 
Returns:
object

Ax.db.of

static object Ax.db.of(
	string name
)
Parameters:
name - the name of the db to connect
Returns:
object

Ax.db.of

static object Ax.db.of(
	string name,
	boolean nonPooledConnection
)
Info:
Gets a connection by db name from provider on same "connection" server.
Parameters:
name - the name of the db to connect
nonPooledConnection - if true, connection will not be from pool (will be new to be use and closed at end)
Returns:
object

Ax.db.of

static object Ax.db.of(
	string server,
	string name
)
Parameters:
server - name of the server to connect to
name - the name of the db to connect
Returns:
object

Ax.db.of

static object Ax.db.of(
	string server,
	string name,
	boolean nonPooledConnection
)
Info:
Gets a connection by db name from provider on a given server an database name.
Parameters:
server - name of the server to connect to
name - name of the db to connect to
nonPooledConnection - if true, connection will not be from pool (will be new to be use and closed at end)
Returns:
object

Ax.db.ofNonPooled

static object Ax.db.ofNonPooled(
	string name
)
Parameters:
name - the name of the db to connect
Returns:
object

Ax.db.ofNonPooled

static object Ax.db.ofNonPooled(
	string server,
	string name
)
Parameters:
server - 
name - 
Returns:
object

Ax.db.releaseConnections

static null Ax.db.releaseConnections()
Info:
This method is called at JSScriptRunner end. So it's not a Closeable and it's not handled like other Closeable script classes
Returns:
null

Ax.db.rollbackWork

static null Ax.db.rollbackWork()
Info:
Ends a failed transaction.
Returns:
null

Ax.db.setConnection

static null Ax.db.setConnection(
	object conn
)
Info:
Redirect current Ax connection to the new connection specified. This causes the release of current connection statements
Parameters:
conn - 
Returns:
null

Ax.db.setDebug

static null Ax.db.setDebug(
	boolean debug
)
Info:
Notify database connection debug is enabled, this will cause some classes using connection may enable debug log. For example, TableInsert ...
Parameters:
debug - true to enable debug, false otherwise
Returns:
null

Ax.db.setPreparedStatementCache

static null Ax.db.setPreparedStatementCache(
	boolean mode
)
Info:
Enable or disable the use of prepared statements cache. True by default. In some cases we need to disable it when non constant statement with arguments is executed.
Parameters:
mode - true to enable cache, false to disable it
Returns:
null

Ax.db.setPreparedStatementCache

static null Ax.db.setPreparedStatementCache(
	smallint size
)
Info:
Sets the cache size. Default size is 1000.
Parameters:
size - cache size
Returns:
null

Ax.db.setSPLDebug

static string Ax.db.setSPLDebug(
	boolean on
)
Info:
Creates a SPL procedure named set_debug on current database. It sets a global variable gl_debug to the input value. If debug is on, it also setup debug to a file with the format DATABASE.USER.SESSIONID.log Returns the file name that will be used for debug
Parameters:
on - value of gl_debug
Returns:
string

Ax.db.statistics

static object Ax.db.statistics()
Info:
Gets the statistics at this moment.
Returns:
object

Ax.db.submit

static long Ax.db.submit(
	object sql,
	object consumer
)
Info:
Runs an async task
Parameters:
sql - 
consumer - 
Returns:
long

Example
Copy
var id = Ax.db.submit(sql, t - {
      t.setOnComplete("....");
      t.setOnError("....");
   }
 );
 console.log("Started task " + id);

Ax.db.supportsTransactions

static boolean Ax.db.supportsTransactions()
Info:
Checks if the connection supports transactions.
Returns:
boolean

Ax.db.toDateQuery

static string Ax.db.toDateQuery(
	date d
)
Info:
Converts a Date (javascript or java) to it's corresponding database date function.
Parameters:
d - the date to convert
Returns:
string

Ax.db.toDateQuery

static string Ax.db.toDateQuery(
	object src
)
Info:
Converts a Date (javascript or java) to it's corresponding database date function.
Parameters:
src - the date to convert
Returns:
string

Ax.db.toString

static string Ax.db.toString()
Info:
Returns a string with the connection database and server names with the format: db@srv . Same as getDatabaseAtServer().
Returns:
string

Ax.db.update

static object Ax.db.update(
	string tableName,
	object rowData
)
Info:
Updates a row using automatic primary key detection and NO where condition rowData is a JSON with the format {colname: value, ...}. It does not work with temporary tables as primary key can not be automatically determined.
Parameters:
tableName - name of thetable to update
rowData - map(JSON) with update data
Returns:
object

Example
Copy
Ax.db.update("t1", { "c1": 1, "c2" : "bye" });

Ax.db.update

static object Ax.db.update(
	string tableName,
	object rowData,
	string condition
)
Info:
Updates a row using a where condition and NO primary key:
Parameters:
tableName - name of the table
rowData - update data
condition - 
Returns:
object

Example
Copy
Ax.db.update("t1", { "c2" : "bye" }, "c1 = 1");
Example
Copy
Ax.db.update("t1", { "c1": 1, "c2" : "bye" }, null);
Example
Copy
Ax.db.update("t1", { "c1": 1, "c2" : "bye" }, "c3 IS NULL");

Ax.db.update

static object Ax.db.update(
	string tableName,
	object dataMap,
	object keysMap
)
Info:
Updates a row. keysMap contains the key columns for 'recognizing' the column to update. The keysMap and dataMap in JS are a JSON of the form {colname: value, ...}.
Parameters:
tableName - name of the table
dataMap - map(JSON) with the update data
keysMap - map(JSON) with the key columns for the update
Returns:
object

Ax.db.update

static object Ax.db.update(
	string tableName,
	object dataMap,
	object keysMap,
	string condition
)
Info:
Updates a row. keysMap contains the key columns for 'recognizing' the column to update. The keysMap and dataMap in JS are a JSON of the form {colname: value, ...}.
Parameters:
tableName - name of the table
dataMap - map(JSON) with the update data
keysMap - map(JSON) with the key columns for the update
condition - optional extra where condition (EXISTS ... CASE .. etc)
Returns:
object

Ax.db.updateBatch

static object Ax.db.updateBatch(
	string tableName
)
Info:
Creates an update batch object to update table passed as parameter.
Parameters:
tableName - name of the table to execute the batch update
Returns:
object

Ax.db.updateOrInsert

static object Ax.db.updateOrInsert(
	string tableName,
	object rowData
)
Info:
Insert or Updates row provided in columnMap. pk columns are automatically extracted from rowData. rowData in JS is a JSON of the form {colname: value, ...}
Parameters:
tableName - name of the table
rowData - data to insert / update
Returns:
object

Ax.db.updateOrInsert

static object Ax.db.updateOrInsert(
	string tableName,
	object dataMap,
	object keysMap
)
Info:
Try insert data, if it fails ( eg: tried to duplicate a pk), then update The keysMap and dataMap in JS are a JSON of the form {colname: value, ...}.
Parameters:
tableName - name of the table
dataMap - map(JSON) with the data to insert / update
keysMap - map(JSON) with the key columns for the update
Returns:
object

2 JSResultSet

Class deister.axional.script.lib.ax.rs.JSResultSet


A Wrapper of ResultSet (either JDBCResultSet or SQLResultSet)

Constructor Summary

Method
Description
JSResultSet(Ax.db conn, T rs)
Creates a new instance from a source ResultSet and a DB connection.
JSResultSet(T rs)
Creates a new instance from a source ResultSet.

Method Summary

Modifier and Type
Method
Description
Ax.text.String 
asJSON()
This is a vanilla JSON, not convertible back to ResultSet
void 
void 
Moves the cursor to the position before the first row.
void 
close()
Closes the ResultSet.
boolean 
closeIfNeed(Ax.text.String cause)
Closes the ResultSet only if not closed already.
cols()
Returns a ISQLResultSetCols to work with the ResultSet columns.
Compare two resultset withs a default delta
compare(IResultSetConvertible other, double delta)
cursor()
void 
boolean 
Compare two resultset withs a default delta
boolean 
equals(IResultSetConvertible other, double delta)
int 
findColumn(Ax.text.String columnName)
Returns the column index in the ResultSet.
Like toOne but will not fail if more than one row.
getAttribute(Ax.text.String name)
Gets the value of the attribute.
Ax.text.String 
getColumnLocalizedValue(Ax.text.String lang, int columnIndex)
Gets the localized value of a column.
Ax.text.String 
getColumnLocalizedValue(LocaleFormatter formater,int columnIndex)
Gets the localized value of a column.
Ax.text.String 
getColumnLocalizedValue(Ax.util.locale.Formatter formater, int columnIndex)
Gets the localized value of a column.
Ax.text.String 
getColumnType(Ax.text.String colname)
Gets a human readable version of column type (useful to determine data type).
Ax.db 
Returns the ResultSet db connection.
Returns an ExtendedResultSetMetaData to obtain and analyze the ResultSet metadata.
int 
Expose final method from MemoryResultSetStore so we can access to the object_id.
int 
Expose final method from MemoryResultSetStore so we can access to the parent_id.
int 
getRow()
Gets the current row number.
int 
Gets the number of rows loaded in memory ResultSet or -1 if it's unknown (because it's a JDBC ResultSet).
Ax.text.String 
getSQL()
Returns the ResultSet SQL query.
Ax.text.String 
Gets the ResultSet title
boolean 
boolean 
isColumnNullable(Ax.text.String colname)
Checks if the column is nullable.
boolean 
isColumnNumeric(int sqltype)
boolean 
Checks if the ResultSet is in memory.
boolean 
Returns an Iterator over the rows of the ResultSet.
Ax.text.String 
ltrim(Ax.text.String s)
Left trim empty spaces
boolean 
next()
Moves the cursor forward one row from its current position.
boolean 
Moves the cursor backwards one row from its current position.
boolean 
Trick to avoid double de-registration fail cause when a JSResultSet created in an internal context is de-registered first on it and later (as it's a return value) it's again tried to de-register in the top context.
rows()
Returns a ISQLResultSetCols to work with the ResultSet rows.
Ax.text.String 
rtrim(Ax.text.String s)
Right trim empty spaces
void 
setAttribute(Ax.text.String name,Object value)
Sets an attribute for the ResultSet.
setTitle(Ax.text.String title)
Sets a title for the ResultSet
stream()
Returns a sequential stream from the ResultSet.
List 
Returns the resultSet as a Java array (array of arrays).
List 
toArray(Ax.text.String columnName)
Same as toArray() but for a single column so it will return the column only.
List 
Convert the ResultSet into an array of Objects (useful to return to Javascript).
List 
toArray(ResultSet rs,Ax.text.String columnName)
Convert the ResultSet into a List
Ax.text.String 
toCSV()
Convert a ResultSet to CSV
void 
Convert a ResultSet to CSV using a provided configurator
byte[] 
Convert a ResultSet to Excel without consumer, returning directly it's bytes using default type (XLSX)
void 
Convert a ResultSet to CSV using a provided configurator
Ax.text.String 
toFOP()
Ax.text.String 
Convert the ResultSet to a FOP XML document
Ax.text.String 
toFOPTableBody(double width)
Ax.text.String 
toFOPTableBody(Consumer<FOPReportConfig> config,double width)
Convert the ResultSet to a FOP XML table body document so it can be integrated into another document
Ax.text.String 
toHTML()
Ax.text.String 
Convert the ResultSet to a HTML document
Ax.text.String 
toJSON()
Converts the ResultSet to a JSON in a format that is convertible back to a ResultSet.
Ax.text.String 
Convert a ResultSet to JSON
List 
Same as toOne() we should return a JSON array (at least immutable).
List 
Convert the ResultSet into an array of Maps (useful to return to Javascript).
Ax.text.String 
Convert the ResultSet to a Javascript declaration (useful for coding)
toMapByKey(String[] columns)
toMapByKey(ResultSet rs, String[] columns)
Class to handle the Map
Returns a JSResultSet wrapping a memory SQLResultSetArray so it can be iterated * many times.
toOne()
Returns the current row as JSON map fetching it and ensuring no more rows exists.
toOne(Ax.text.String errorMessageIfNotOne)
byte[] 
toPDF()
byte[] 
Convert the ResultSet to a PDF document
byte[] 
toPDF(Ax.text.String fop)
Useful method for testing so we can produce a FOP and transform to PDF
Returns a ResultSet from the JSResultset object.
Perform a conversion to resultset
toRow()
Creates a Row map for the ResultSet at current row position
toSQLCA(Object value)
Converts the object to SQLCA
Ax.text.String 
Returns a string with the ResultSet contents.
Ax.text.String 
toText()
Ax.text.String 
Convert the ResultSet to a TEXT document
Returns an object from the single-row single-column ResultSet.
byte[] 
toXLS()
Convert a ResultSet to Excel (XLS)
byte[] 
toXLSX()
Convert a ResultSet to Excel (XLSX using streaming api)
Ax.text.String 
trimNull(Ax.text.String str)
Convert a empty string to null
void 
update(Ax.text.String columnName,Object value)
void 

Constructor Detail

deister.axional.script.lib.ax.rs.JSResultSet.JSResultSet

deister.axional.script.lib.ax.rs.JSResultSet.JSResultSet(
	object conn,
	object rs
						)
Info:
Creates a new instance from a source ResultSet and a DB connection.
Parameters:
conn - the db connection
rs - the source ResultSet

deister.axional.script.lib.ax.rs.JSResultSet.JSResultSet

deister.axional.script.lib.ax.rs.JSResultSet.JSResultSet(
	object rs
						)
Info:
Creates a new instance from a source ResultSet.
Parameters:
rs - the source ResultSet

Method Detail

deister.axional.script.lib.ax.rs.JSResultSet.__toResultSet

resultset deister.axional.script.lib.ax.rs.JSResultSet.__toResultSet(
	object value
)
Parameters:
value - 
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.asJSON

string deister.axional.script.lib.ax.rs.JSResultSet.asJSON()
Info:
This is a vanilla JSON, not convertible back to ResultSet
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.asJSON

null deister.axional.script.lib.ax.rs.JSResultSet.asJSON(
	object config
)
Parameters:
config - 
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.beforeFirst

null deister.axional.script.lib.ax.rs.JSResultSet.beforeFirst()
Info:
Moves the cursor to the position before the first row. WARNING: Calling this function on Forward-only ResultSets generates an Exception.
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.close

null deister.axional.script.lib.ax.rs.JSResultSet.close()
Info:
Closes the ResultSet.
Returns:
null

Example
Copy
var rs = Ax.db.executeQuery("SELECT ..");
 rs.close();

deister.axional.script.lib.ax.rs.JSResultSet.closeIfNeed

boolean deister.axional.script.lib.ax.rs.JSResultSet.closeIfNeed(
	string cause
)
Info:
Closes the ResultSet only if not closed already.
Parameters:
cause - the closing cause
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.cols

object deister.axional.script.lib.ax.rs.JSResultSet.cols()
Info:
Returns a ISQLResultSetCols to work with the ResultSet columns.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.compare

object deister.axional.script.lib.ax.rs.JSResultSet.compare(
	object other
)
Info:
Compare two resultset withs a default delta
Parameters:
other - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.compare

object deister.axional.script.lib.ax.rs.JSResultSet.compare(
	object other,
	double delta
)
Parameters:
other - 
delta - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.cursor

object deister.axional.script.lib.ax.rs.JSResultSet.cursor()
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.deleteRow

null deister.axional.script.lib.ax.rs.JSResultSet.deleteRow()
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.equals

boolean deister.axional.script.lib.ax.rs.JSResultSet.equals(
	object other
)
Info:
Compare two resultset withs a default delta
Parameters:
other - 
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.equals

boolean deister.axional.script.lib.ax.rs.JSResultSet.equals(
	object other,
	double delta
)
Parameters:
other - 
delta - 
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.findColumn

smallint deister.axional.script.lib.ax.rs.JSResultSet.findColumn(
	string columnName
)
Info:
Returns the column index in the ResultSet.
Parameters:
columnName - the column name
Returns:
smallint

deister.axional.script.lib.ax.rs.JSResultSet.firstOne

object deister.axional.script.lib.ax.rs.JSResultSet.firstOne()
Info:
Like toOne but will not fail if more than one row. It's like SQL SELECT FIRST 1.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.getAttribute

object deister.axional.script.lib.ax.rs.JSResultSet.getAttribute(
	string name
)
Info:
Gets the value of the attribute.
Parameters:
name - the attribute name
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue

string deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue(
	string lang,
	smallint columnIndex
)
Info:
Gets the localized value of a column.
Parameters:
lang - the language to get the locale
columnIndex - the index of the column to get
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue

string deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue(
	object formater,
	smallint columnIndex
)
Info:
Gets the localized value of a column.
Parameters:
formater - the locale formatter to use to get the localized value
columnIndex - the index of the column to get
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue

string deister.axional.script.lib.ax.rs.JSResultSet.getColumnLocalizedValue(
	object formater,
	smallint columnIndex
)
Info:
Gets the localized value of a column.
Parameters:
formater - the locale formatter to use to get the localized value
columnIndex - the index of the column to get
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.getColumnType

string deister.axional.script.lib.ax.rs.JSResultSet.getColumnType(
	string colname
)
Info:
Gets a human readable version of column type (useful to determine data type).
Parameters:
colname - the name of the column
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.getConnection

object deister.axional.script.lib.ax.rs.JSResultSet.getConnection()
Info:
Returns the ResultSet db connection.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.getMetaData

object deister.axional.script.lib.ax.rs.JSResultSet.getMetaData()
Info:
Returns an ExtendedResultSetMetaData to obtain and analyze the ResultSet metadata.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.getObjectId

smallint deister.axional.script.lib.ax.rs.JSResultSet.getObjectId()
Info:
Expose final method from MemoryResultSetStore so we can access to the object_id.
Returns:
smallint

deister.axional.script.lib.ax.rs.JSResultSet.getParentId

smallint deister.axional.script.lib.ax.rs.JSResultSet.getParentId()
Info:
Expose final method from MemoryResultSetStore so we can access to the parent_id.
Returns:
smallint

deister.axional.script.lib.ax.rs.JSResultSet.getRow

smallint deister.axional.script.lib.ax.rs.JSResultSet.getRow()
Info:
Gets the current row number.
Returns:
smallint

deister.axional.script.lib.ax.rs.JSResultSet.getRowCount

smallint deister.axional.script.lib.ax.rs.JSResultSet.getRowCount()
Info:
Gets the number of rows loaded in memory ResultSet or -1 if it's unknown (because it's a JDBC ResultSet).
Returns:
smallint

deister.axional.script.lib.ax.rs.JSResultSet.getSQL

string deister.axional.script.lib.ax.rs.JSResultSet.getSQL()
Info:
Returns the ResultSet SQL query.
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.getTitle

string deister.axional.script.lib.ax.rs.JSResultSet.getTitle()
Info:
Gets the ResultSet title
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.isClosed

boolean deister.axional.script.lib.ax.rs.JSResultSet.isClosed()
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.isColumnNullable

boolean deister.axional.script.lib.ax.rs.JSResultSet.isColumnNullable(
	string colname
)
Info:
Checks if the column is nullable.
Parameters:
colname - the name of the column to check
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.isColumnNumeric

boolean deister.axional.script.lib.ax.rs.JSResultSet.isColumnNumeric(
	smallint sqltype
)
Parameters:
sqltype - 
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.isMemory

boolean deister.axional.script.lib.ax.rs.JSResultSet.isMemory()
Info:
Checks if the ResultSet is in memory.
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.isResultSet

boolean deister.axional.script.lib.ax.rs.JSResultSet.isResultSet(
	object value
)
Parameters:
value - 
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.iterator

object deister.axional.script.lib.ax.rs.JSResultSet.iterator()
Info:
Returns an Iterator over the rows of the ResultSet.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.ltrim

string deister.axional.script.lib.ax.rs.JSResultSet.ltrim(
	string s
)
Info:
Left trim empty spaces
Parameters:
s - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.next

boolean deister.axional.script.lib.ax.rs.JSResultSet.next()
Info:
Moves the cursor forward one row from its current position.
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.pivot

resultset deister.axional.script.lib.ax.rs.JSResultSet.pivot(
	object config
)
Parameters:
config - 
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.previous

boolean deister.axional.script.lib.ax.rs.JSResultSet.previous()
Info:
Moves the cursor backwards one row from its current position. WARNING: Calling this function on Forward-only ResultSets generates an Exception.
Returns:
boolean

deister.axional.script.lib.ax.rs.JSResultSet.requiresDeRegister

boolean deister.axional.script.lib.ax.rs.JSResultSet.requiresDeRegister()
Info:
Trick to avoid double de-registration fail cause when a JSResultSet created in an internal context is de-registered first on it and later (as it's a return value) it's again tried to de-register in the top context. The problem is caused by a call to a function. We have the first context and the context of the function. The internal function return deregisters the resultset and the second return again!
Returns:
boolean

Example
Copy
var mSQLCond = Ax.context.property.COND.toString();
	    var mSort    = Ax.context.variable.ORDERBY;
	    
	    return Ax.db.call("capuntesComp", mSQLCond, mSort)

deister.axional.script.lib.ax.rs.JSResultSet.rows

object deister.axional.script.lib.ax.rs.JSResultSet.rows()
Info:
Returns a ISQLResultSetCols to work with the ResultSet rows.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.rtrim

string deister.axional.script.lib.ax.rs.JSResultSet.rtrim(
	string s
)
Info:
Right trim empty spaces
Parameters:
s - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.setAttribute

null deister.axional.script.lib.ax.rs.JSResultSet.setAttribute(
	string name,
	object value
)
Info:
Sets an attribute for the ResultSet.
Parameters:
name - the attribute name
value - the attribute value
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.setTitle

resultset deister.axional.script.lib.ax.rs.JSResultSet.setTitle(
	string title
)
Info:
Sets a title for the ResultSet
Parameters:
title - the title to set
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.stream

object deister.axional.script.lib.ax.rs.JSResultSet.stream()
Info:
Returns a sequential stream from the ResultSet.
Returns:
object

Example
Copy
var rs_list = Ax.db.executeQuery(`
     SELECT * FROM systables
 `);

 var rs_filter = rs_list.stream().filter(f => f.getString("tabname").equals("systables")).toResultSet();
 // We will have a new ResultSet with only the row marching "tabname=systables"
 console.log(rs_filter);

deister.axional.script.lib.ax.rs.JSResultSet.toArray

array deister.axional.script.lib.ax.rs.JSResultSet.toArray()
Info:
Returns the resultSet as a Java array (array of arrays).
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toArray

array deister.axional.script.lib.ax.rs.JSResultSet.toArray(
	string columnName
)
Info:
Same as toArray() but for a single column so it will return the column only.
Parameters:
columnName - 
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toArray

array deister.axional.script.lib.ax.rs.JSResultSet.toArray(
	resultset rs
)
Info:
Convert the ResultSet into an array of Objects (useful to return to Javascript).
Parameters:
rs - 
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toArray

array deister.axional.script.lib.ax.rs.JSResultSet.toArray(
	resultset rs,
	string columnName
)
Info:
Convert the ResultSet into a List
Parameters:
rs - 
columnName - 
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toCSV

string deister.axional.script.lib.ax.rs.JSResultSet.toCSV()
Info:
Convert a ResultSet to CSV
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toCSV

null deister.axional.script.lib.ax.rs.JSResultSet.toCSV(
	object config
)
Info:
Convert a ResultSet to CSV using a provided configurator
Parameters:
config - 
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.toExcel

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toExcel()
Info:
Convert a ResultSet to Excel without consumer, returning directly it's bytes using default type (XLSX)
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.toExcel

null deister.axional.script.lib.ax.rs.JSResultSet.toExcel(
	object config
)
Info:
Convert a ResultSet to CSV using a provided configurator
Parameters:
config - 
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.toFOP

string deister.axional.script.lib.ax.rs.JSResultSet.toFOP()
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toFOP

string deister.axional.script.lib.ax.rs.JSResultSet.toFOP(
	object config
)
Info:
Convert the ResultSet to a FOP XML document
Parameters:
config - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toFOPTableBody

string deister.axional.script.lib.ax.rs.JSResultSet.toFOPTableBody(
	double width
)
Parameters:
width - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toFOPTableBody

string deister.axional.script.lib.ax.rs.JSResultSet.toFOPTableBody(
	object config,
	double width
)
Info:
Convert the ResultSet to a FOP XML table body document so it can be integrated into another document
Parameters:
config - 
width - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toHTML

string deister.axional.script.lib.ax.rs.JSResultSet.toHTML()
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toHTML

string deister.axional.script.lib.ax.rs.JSResultSet.toHTML(
	object config
)
Info:
Convert the ResultSet to a HTML document
Parameters:
config - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toJSON

string deister.axional.script.lib.ax.rs.JSResultSet.toJSON()
Info:
Converts the ResultSet to a JSON in a format that is convertible back to a ResultSet.
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toJSON

string deister.axional.script.lib.ax.rs.JSResultSet.toJSON(
	object config
)
Info:
Convert a ResultSet to JSON
Parameters:
config - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toJSONArray

array deister.axional.script.lib.ax.rs.JSResultSet.toJSONArray()
Info:
Same as toOne() we should return a JSON array (at least immutable).
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toJSONArray

array deister.axional.script.lib.ax.rs.JSResultSet.toJSONArray(
	resultset rs
)
Info:
Convert the ResultSet into an array of Maps (useful to return to Javascript).
Parameters:
rs - 
Returns:
array

deister.axional.script.lib.ax.rs.JSResultSet.toJavaScript

string deister.axional.script.lib.ax.rs.JSResultSet.toJavaScript()
Info:
Convert the ResultSet to a Javascript declaration (useful for coding)
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toMapByKey

object deister.axional.script.lib.ax.rs.JSResultSet.toMapByKey(
	string[] columns
)
Parameters:
columns - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toMapByKey

object deister.axional.script.lib.ax.rs.JSResultSet.toMapByKey(
	resultset rs,
	string[] columns
)
Info:
Class to handle the Map
Parameters:
rs - 
columns - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toMemory

resultset deister.axional.script.lib.ax.rs.JSResultSet.toMemory()
Info:
Returns a JSResultSet wrapping a memory SQLResultSetArray so it can be iterated * many times.
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.toOne

object deister.axional.script.lib.ax.rs.JSResultSet.toOne()
Info:
Returns the current row as JSON map fetching it and ensuring no more rows exists. We return a JSObject instead of ResultSetRowMap cause even Nashorn hanles perfectly the Map in javascript, if we want to compose a JSON object using this as element it will not really be composed of JSONs. The case comes when we want to send a composed JSON object combining various JSONs and JSON arrays. Even this object can be handled by Nashorn, if we build it using ResultSetRowMap for invoice an company and and List
Returns:
object

Example
Copy
for items, it is not really composed of JSON objects.

 If not rows, the map contains the keys with null values.

 
 
 var json = {
   invoice : Ax.db.executeQuery("SELECT invoiceNumber, invocieDate as date, total FROM invoice WHERE invoiceNumber = ?", number).toOne(),
   company : Ax.db.executeQuery("SELECT * FROM company where company_id = (SELECT company_id FROM invoice WHERE invoiceNumber = ?)", number).toOne(),
   items   : Ax.db.executeQuery("SELECT * FROM items WHERE invoiceNumber = ? ORDER BY seqno", number).toArray()
 }

deister.axional.script.lib.ax.rs.JSResultSet.toOne

object deister.axional.script.lib.ax.rs.JSResultSet.toOne(
	string errorMessageIfNotOne
)
Parameters:
errorMessageIfNotOne - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toPDF

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toPDF()
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.toPDF

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toPDF(
	object config
)
Info:
Convert the ResultSet to a PDF document
Parameters:
config - 
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.toPDF

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toPDF(
	string fop
)
Info:
Useful method for testing so we can produce a FOP and transform to PDF
Parameters:
fop - 
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.toResultSet

resultset deister.axional.script.lib.ax.rs.JSResultSet.toResultSet()
Info:
Returns a ResultSet from the JSResultset object.
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.toResultSet

resultset deister.axional.script.lib.ax.rs.JSResultSet.toResultSet(
	object value
)
Info:
Perform a conversion to resultset
Parameters:
value - 
Returns:
resultset

deister.axional.script.lib.ax.rs.JSResultSet.toRow

object deister.axional.script.lib.ax.rs.JSResultSet.toRow()
Info:
Creates a Row map for the ResultSet at current row position
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toSQLCA

object deister.axional.script.lib.ax.rs.JSResultSet.toSQLCA(
	object value
)
Info:
Converts the object to SQLCA
Parameters:
value - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toString

string deister.axional.script.lib.ax.rs.JSResultSet.toString()
Info:
Returns a string with the ResultSet contents. Allows console.log(db.executeQuery(...));
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toText

string deister.axional.script.lib.ax.rs.JSResultSet.toText()
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toText

string deister.axional.script.lib.ax.rs.JSResultSet.toText(
	object config
)
Info:
Convert the ResultSet to a TEXT document
Parameters:
config - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.toValue

object deister.axional.script.lib.ax.rs.JSResultSet.toValue()
Info:
Returns an object from the single-row single-column ResultSet.
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toValue

object deister.axional.script.lib.ax.rs.JSResultSet.toValue(
	resultset rs
)
Parameters:
rs - 
Returns:
object

deister.axional.script.lib.ax.rs.JSResultSet.toXLS

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toXLS()
Info:
Convert a ResultSet to Excel (XLS)
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.toXLSX

byte[] deister.axional.script.lib.ax.rs.JSResultSet.toXLSX()
Info:
Convert a ResultSet to Excel (XLSX using streaming api)
Returns:
byte[]

deister.axional.script.lib.ax.rs.JSResultSet.trimNull

string deister.axional.script.lib.ax.rs.JSResultSet.trimNull(
	string str
)
Info:
Convert a empty string to null
Parameters:
str - 
Returns:
string

deister.axional.script.lib.ax.rs.JSResultSet.update

null deister.axional.script.lib.ax.rs.JSResultSet.update(
	string columnName,
	object value
)
Parameters:
columnName - 
value - 
Returns:
null

deister.axional.script.lib.ax.rs.JSResultSet.updateRow

null deister.axional.script.lib.ax.rs.JSResultSet.updateRow()
Returns:
null