The HCL
OneDB™ JSON
commands are available in addition to the supported MongoDB commands.
These commands enable functionality that is supported by HCL
OneDB and
they are run by using the MongoDB API.
The syntax for using HCL
OneDB
commands in the MongoDB shell is:
db.runCommand({command_document})
The
command_document contains the HCL
OneDB command and any parameters.
Important: If you create text indexes by using the HCL
OneDB createTextIndex
command, you must query them by using the HCL
OneDB $ifxtext
query operator. If you create text indexes by using the MongoDB syntax
for text indexes, you must query them by using the MongoDB $text
query operator.
This required parameter specifies the name of the collection or relational table where
the BTS index is created.
name
This required parameter specifies the name of the BTS index.
options
This required parameter specifies the name-value pairs for the BTS parameters that are
used when creating the index. If no parameter values are required, you can specify an
empty document.
Use BTS index parameters to customize the behavior of the index and how text is
indexed. Include JSON index parameters to control how JSON and BSON documents are
indexed. For example, you can index the documents as field name-value pairs instead of
as unstructured text so that you can search for text by field. The name and values of
the BTS index parameters in the options parameter are the same as the syntax for
creating a BTS access method with the SQL CREATE INDEX statement. The following example
creates an index named articlesIdx on the articles collection by using the BTS parameter
all_json_names="yes":
This parameter is required if you are indexing relational tables,
but optional if you are indexing collections. This parameter specifies
which columns to index for relational tables.
The following example creates an index named myidx in the mytab relational table on
the title and abstract
columns:
Where "n" is the number of documents that are exported,
"millis" is the number of milliseconds it took to export, and
"rate" is the number of documents per second that are
exported.
jsonArray
The .jsonArray file format. This format exports
an array of JSON-serialized documents with no line breaks. The array
format is JSON-standard.
The following command exports all documents from the collection
c by using the jsonArray format:
Where "n" is the number of documents
that are exported, "millis" is the number of milliseconds
it took to export, and "rate" is the number of documents
per second that are exported.
csv
The .csv file format. Comma-separated values
are exported. You must specify which fields to export from each document.
The first line of the .csv file contains the
fields and all subsequent lines contain the comma-separated document
values.
fields
This parameter specifies which fields are included in the output
file. This parameter is required for the csv format,
but optional for the json and jsonArray formats.
The following command exports all documents from the collection that is named c by
using the csv format, only output the "_id" and "name" fields:
This optional parameter specifies a query document that identifies which documents are
exported. The following example exports all documents from the collection that is named
c that have a "qty" field that is less than 100:
To run this command, you must be the instance administrator.
If you specify the lockAccounts:1 command without specifying a
db or user argument, all accounts in all
databases are locked.
lockAccounts:1
This required parameter locks a database or user account.
db
This optional parameter specifies the database name of an account to lock. For
example, to lock all accounts in database that is named foo:
> db.runCommand({lockAccounts: 1 ,db: "foo"})
exclude
This optional parameter specifies the databases to exclude. For example, to
lock all accounts on the system except the accounts that are in the databases
named alpha and
beta:
This optional MongoDB
evaluation query operator selects values from a specified JSON document. For
example, to lock accounts for databases that begin with the character
a. and end in
e:
This parameter specifies an array of argument values to the function. You must provide as many
arguments as the function requires. For example, an add_values function requires
two arguments to add
together:
Run an SQL stored procedure through the wire listener. This command is equivalent to the SQL
statement EXECUTE PROCEDURE.
runProcedure
This required parameter specifies the name of the SQL procedure to run. For example, a
colors_list stored procedure, which uses a WITH RESUME clause in its RETURN
statement, returns multiple rows about
colors:
This parameter specifies an array of argument values to the procedure. You must provide as many
arguments as the procedure requires. For example, an increase_price procedure
requires two arguments to identify the original price and the amount of
increase:
Enable or disable transaction support for a session, run a batch transaction, or, when
transaction support is enabled, commit or rollback transactions. This command binds or unbinds a
connection to the current MongoDB session in
a database. The relationship between a MongoDB session and the HCL
OneDB JDBC connection
is not static.
Important: This command is not supported for queries that are run on
shard servers.
enable
This optional parameter enables transaction mode for the current session in the
current database. The following example shows how to enable transaction
mode:
> db.runCommand({transaction: "enable"})
{"ok":1}
disable
This optional parameter disables transaction mode for the current session in the
current database. The following example shows how to disable for transaction mode:
If transactions are enabled, this optional parameter commits the current transaction. If
transactions are disabled, an error is shown. The following example shows how to commit
the current
transaction:
If transactions are enabled, this optional parameter rolls back the current transaction. If
transactions are disabled, an error is shown. The following example shows how to roll
back the current
transaction:
This optional parameter runs a batch of commands as a single transaction. If transaction mode is
not enabled for the session, this parameter enables transaction mode for the duration of the
transaction.
The list of command documents can include insert, update,
delete, findAndModify, and
find command documents. In insert,
update, and delete command documents, you cannot
set the ordered property to false. You can use a
find command document to run queries, including SQL queries, but
not commands. A find command document can include the
$orderby, limit, skip,
and sort operators. The following example deletes a document from
the inventory collection and inserts documents into the archive
collection:
Include the optional finally argument if you have a set of command
documents to run at the end of the transaction regardless of whether the transaction is successful.
The following example runs a query with the . The command document for the
finally argument unsets the USE_DWA environment variable regardless of whether
the previous query succeeds.
> db.runCommand({"transaction" : "execute",
"commands" : [
{"find" : "system.sql", "filter" : {"$sql" :
"SET ENVIRONMENT USE_DWA 'ACCELERATE ON'" } },
{"find" : "system.sql", "filter" : {"$sql" :
"SELECT SUM(s.amount) as sum FROM sales AS s
WHERE s.prid = 100 GROUP BY s.zip" } }
],
"finally" : [{"find":"system.sql", "filter" : {"$sql" :
"SET ENVIRONMENT USE_DWA 'ACCELERATE OFF'" } } ]
})
status
This optional parameter prints status information to indicate whether transaction mode
is enabled, and if transactions are supported by the current database. The following
example shows how to print status
information:
To run this command, you must be the instance administrator.
If you specify the unlockAccounts:1 command without
specifying a db or user argument,
all accounts in all databases are unlocked.
unlockAccounts:1
This required parameter unlocks a database or user account.
db
This optional parameter specifies the database name of an account to unlock. For example, to
unlock all accounts in database that is named
foo:
> db.runCommand({unlockAccounts: 1, db: "foo"})
exclude
This optional parameter specifies the databases to exclude. For example, to unlock all accounts
on the system except the accounts that are in the databases named
alpha and
beta:
This optional MongoDB evaluation query
operator selects values from a specified JSON document. For example, to unlock
accounts for databases that begin with the character a. and end
in
e: