Extensions.SQL.ExecuteQuery

From emotive
Revision as of 09:20, 24 September 2019 by Nb (talk | contribs) (→‎Properties: Edited by Ngoc Tran.)
Jump to navigation Jump to search

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