Difference between revisions of "Extensions.SQL.ExecuteQuery"

From emotive
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:OTX '''ExecuteQuery'''}}Category:SQL == Classification == {{ClassificationActivity | ExecuteQuery | Execute the given OTX SQL Extension statement | Action...")
 
(→‎Properties: Edited by Ngoc Tran.)
Line 15: Line 15:
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie2| connection| [[Extensions.SQL.ConnectionTerm|ConnectionTerm]] | [[Variable]] | - | [1..1] | This element represents an open [[Extensions.SQL.Connection|Connection]]}}
+
{{TableRowPropertie2| connection| [[Extensions.SQL.Connection|Connection]] | [[Term]] | - | [1..1] | This element represents an open [[Extensions.SQL.Connection|Connection]]}}
{{TableRowPropertie2| statement| [[Core.DataTypes.SimpleDataType.String|StringTerm]] | [[Variable]] | - | [1..1] | Mandatory [[Extensions.SQL|OTX SQL Extension]] statement string which is send to the database, typically a static [[Extensions.SQL|OTX SQL Extension]] SELECT statement.}}
+
{{TableRowPropertie2| statement| [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1..1] | Mandatory [[Extensions.SQL|OTX SQL Extension]] statement string which is send to the database, typically a static [[Extensions.SQL|OTX SQL Extension]] SELECT statement.}}
{{TableRowPropertie2| resultSet| [[Extensions.SQL.ResultSet|ResultSetVariable]] | [[Variable]] | - | [1..1] | Returns a [[Extensions.SQL.ResultSet|ResultSet]] which contains the result of the executed reading command.}}
+
{{TableRowPropertie2| resultSet| [[Extensions.SQL.ResultSet|ResultSet]] | [[Variable]] | - | [1..1] | Returns a [[Extensions.SQL.ResultSet|ResultSet]] which contains the result of the executed reading command.}}
 
|}
 
|}
  

Revision as of 09:20, 24 September 2019

Classification

Name ExecuteQuery
Short Description Execute the given OTX SQL Extension statement
Class Action
Extension OTX SQL extension
Group SQL related Actions
Exceptions CommandException
ConnectionException
Checker Rules -
Standard Compliant Yes

OTL Syntax

ActionRealisation SQL.ExecuteQuery(ConnectionTerm connection, StringTerm statement, ResultSetVariable resultSet);

Description

The ExecuteQuery action will execute the given OTX SQL Extension statement, which returns a single ResultSet object.
NOTE — After executing a command the ResultSet cursor is initially positioned before the first row.

Properties

Name Data Type Class Default Cardinality Description
connection Connection Term - [1..1] This element represents an open Connection
statement String Term - [1..1] Mandatory OTX SQL Extension statement string which is send to the database, typically a static OTX SQL Extension SELECT statement.
resultSet ResultSet Variable - [1..1] Returns a ResultSet which contains the result of the executed reading command.

OTL Examples

		/// Local Declarations

		SQL.Connection Connection1;
		SQL.ResultSet ResultSet1;
		Boolean Boolean1;
		List<Boolean> List1;

		/// Flow

		try
		{
			// connect with DotNet platform
		        Connection1 = SQL.CreateConnection("DRIVER={SQL Server};Server=.;InitialCatalog=classicmodels;username=sa;password=saas");
		}
		catch (Exception)
		{
			// connect with Java platform
		        Connection1 = SQL.CreateConnection("jdbc:sqlserver://localhost;databaseName=classicmodels;username=sa;password=saas");
		}
		catch (Exception Exception1)
		{
		        throw Exception1;
		}

		SQL.ExecuteQuery(Connection1, "select * from classicmodels.dbo.orders", ResultSet1);

		while (SQL.NextResult(ResultSet1)) : WhileLoop1
		{
			Boolean1 = SQL.GetResultValueAsBoolean(ResultSet1, "hasComments");
			ListAppendItems(List1, {Boolean1});
		}

		if (Util.Compare({List1, {false, true, false, false, false, false, false}}))
		{
			Result = true;
			ErrorMessage = "";
		}

		SQL.CloseConnection(Connection1);

See also

CreateConnection
ExecuteQuery
ExecuteUpdate
GetResultValueAsString
GetResultValueAsInteger
NextResult