Skip to end of banner
Go to start of banner

databaseAvailable

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

<ac:structured-macro ac:name="table-plus" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="columnAttributes">style="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<table data-layout="default">
<colgroup>
<col style="width: 76.0px;" />
<col style="width: 278.0px;" />
<col style="width: 106.0px;" />
<col style="width: 266.0px;" />
</colgroup>
<tbody>
<tr>
<td>
<p><strong>Syntax</strong></p>
</td>
<td>
<p>databaseAvailable(dbstring , sqlstring)</p>
</td>
<td>
<p><strong>Package</strong></p>
</td>
<td>
<p>sql</p>
</td>
</tr>
<tr>
<td>
<p><strong>Alias</strong></p>
</td>
<td>
<p></p>
</td>
<td>
<p><strong>Pkg Usage</strong></p>
</td>
<td>
<p>available(dbstring , sqlstring)</p>
</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<h2>Description</h2>
<p><ac:structured-macro ac:name="excerpt" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="hidden">true</ac:parameter>
<ac:rich-text-body>
Checks if the database is available.
</ac:rich-text-body>
</ac:structured-macro>
<p>Checks if the database is available. Optionally, it can check also the availability of the results for the SQL passed in as the second parameter.</p></p>
<h2>Parameters</h2>
<ac:structured-macro ac:name="table-plus" ac:schema-version="1">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<table data-layout="default">
<colgroup>
<col style="width: 170.0px;" />
<col style="width: 97.0px;" />
<col style="width: 108.0px;" />
<col style="width: 305.0px;" />
</colgroup>
<tbody>
<tr>
<th>
<p>Parameter name</p>
</th>
<th>
<p>Type</p>
</th>
<th>
<p>Required</p>
</th>
<th>
<p>Description</p>
</th>
</tr>
<tr>
<td>
<p>dbstring</p>
</td>
<td>
<p>String</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Datasource JNDI name or the datasource name. For Jira database, this is set to "jdbc/JiraDS" by default, if exported.</p>
</td>
</tr><tr>
<td>
<p>sqlstring</p>
</td>
<td>
<p>String</p>
</td>
<td>
<p>No</p>
</td>
<td>
<p>SQL string.</p>
</td>
</tr>
</tbody></table></ac:rich-text-body></ac:structured-macro>
<h2>Return Type</h2>
<p><strong>Boolean (true/false)</strong></p>

<h2>Examples</h2>
<h3>Example 1</h3>
<p>Let's suppose in our examples `TextField` is a custom field text already configured for the current Jira server instance and `TestDB` represents the database resource name configured in the server context. For more details see <ac:link><ri:page ri:content-title="SQL data sources" /></ac:link>.</p>
<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATATextField=databaseAvailable("TestDB"); //will set 'TextField' value to 'true']>
</ac:plain-text-body>
</ac:structured-macro>

<h3>Example 2</h3>

<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATATextField=databaseAvailable("TestDB", "select pname from project"); //will set 'TextField' value to 'true' if the SQL passed in can be executed]>
</ac:plain-text-body>
</ac:structured-macro>

<h3>Example 3</h3>

<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATATextField=databaseAvailable("TestDB", "select pname from inexistentTableName");//will set 'TextField' value to 'false', because the SQL passed in cannot be executed]>
</ac:plain-text-body>
</ac:structured-macro>

<h3>Example 4</h3>

<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:plain-text-body>
<![CDATATextField=databaseAvailable("InexistentTestDB", "select pname from project");//will set 'TextField' value to 'false', because the database resource does not exist]>
</ac:plain-text-body>
</ac:structured-macro>

<h2>Note</h2>
<p><ac:structured-macro ac:name="note" ac:schema-version="1">
<ac:rich-text-body>
<p>To configure the data source check the <ac:link><ri:page ri:content-title="SQL data sources" /></ac:link> configuration chapter.</p>
</ac:rich-text-body>
</ac:structured-macro></p>

<h2>See also</h2>
<p><ac:structured-macro ac:name="contentbylabel" ac:schema-version="4">
<ac:parameter ac:name="showLabels">false</ac:parameter>
<ac:parameter ac:name="max">25</ac:parameter>
<ac:parameter ac:name="showSpace">false</ac:parameter>
<ac:parameter ac:name="cql">label = "system_routines" and space = currentSpace ( )</ac:parameter>
<ac:parameter ac:name="labels">array_routines</ac:parameter>
</ac:structured-macro></p>

Availability

This routine is available starting with SIL Engine™ 2.6.5.

Syntax

databaseAvailable(dbstring [, sqlstring])

Description

Checks if the database is available. Optionally, it can check also the availability of the results for the SQL passed in as the second parameter.

 

Parameters

Parameter name

Type

Required

Description

dbstring

string

yes

Datasource JNDI name or the datasource name. For Jira database, this is set to "jdbc/JiraDS" by default, if exported.

sqlstring

string

no

SQL string.

Return type

 boolean (true/false)

Example

Let's suppose in our examples `TextField` is a custom field text already configured for the current Jira server instance and `TestDB` represents the database resource name configured in the server context. For more details see SQL Data Source Configuration.

Example 1

TextField=databaseAvailable("TestDB"); //will set `TextField` value to `true`

Example 2

TextField=databaseAvailable("TestDB", "select pname from project"); //will set `TextField` value to `true` if the SQL passed in can be executed

Example 3

TextField=databaseAvailable("TestDB", "select pname from inexistentTableName");//will set `TextField` value to `false`, because the SQL passed in cannot be executed

Example 4

TextField=databaseAvailable("InexistentTestDB", "select pname from project");//will set `TextField` value to `false`, because the database resource does not exist

Notes

To configure the data source check the SQL Data Source Configuration configuration chapter.


See also


 

  • No labels