Difference between revisions of "Extensions.SQL.ExecuteQuery"

From emotive
Jump to navigation Jump to search
(→‎Properties: Edited by Ngoc Tran.)
(Edited by Ngoc Tran.)
 
Line 10: Line 10:
 
== Description ==
 
== Description ==
 
The ExecuteQuery action will execute the given [[Extensions.SQL|OTX SQL Extension]] statement, which returns a single [[Extensions.SQL.ResultSet|ResultSet]] object. <br />
 
The ExecuteQuery action will execute the given [[Extensions.SQL|OTX SQL Extension]] statement, which returns a single [[Extensions.SQL.ResultSet|ResultSet]] object. <br />
NOTE — After executing a command the [[Extensions.SQL.ResultSet|ResultSet]] cursor is initially positioned before the first row.
+
{{Note| After executing a command the [[Extensions.SQL.ResultSet|ResultSet]] cursor is initially positioned before the first row.}}
  
 
== Properties ==
 
== Properties ==
Line 65: Line 65:
  
 
== See also ==
 
== See also ==
[[Extensions.SQL.CreateConnection|CreateConnection]]<br/>
+
{| {{TableHeader}}
[[Extensions.SQL.ExecuteQuery|ExecuteQuery]]<br/>
+
{{TableRowKeyValueList|[[Extensions.SQL.CloseConnection|CloseConnection]]|}}
[[Extensions.SQL.ExecuteUpdate|ExecuteUpdate]]<br/>
+
{{TableRowKeyValueList|[[Extensions.SQL.ExecuteQuery|ExecuteQuery]]|}}
[[Extensions.SQL.GetResultValueAsString|GetResultValueAsString]]<br/>
+
{{TableRowKeyValueList|[[Extensions.SQL.ExecuteUpdate|ExecuteUpdate]]|}}
[[Extensions.SQL.GetResultValueAsInteger|GetResultValueAsInteger]]<br/>
+
{{TableRowKeyValueList|[[Extensions.SQL.ConnectionTerm|ConnectionTerm]]|}}
[[Extensions.SQL.NextResult|NextResult]]
+
{{TableRowKeyValueList|[[Extensions.SQL.ConnectionValue|ConnectionValue]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.CreateConnection|CreateConnection]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.GetResultValueAsBoolean|GetResultValueAsBoolean]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.GetResultValueAsByteField|GetResultValueAsByteField]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.GetResultValueAsFloat|GetResultValueAsFloat]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.GetResultValueAsInteger|GetResultValueAsInteger]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.GetResultValueAsString|GetResultValueAsString]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.NextResult|NextResult]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.ResultSetTerm|ResultSetTerm]]|}}
 +
{{TableRowKeyValueList|[[Extensions.SQL.ResultSetValue|ResultSetValue]]|}}
 +
|}

Latest revision as of 09:39, 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.

Icons Note.png 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

CloseConnection
ExecuteQuery
ExecuteUpdate
ConnectionTerm
ConnectionValue
CreateConnection
GetResultValueAsBoolean
GetResultValueAsByteField
GetResultValueAsFloat
GetResultValueAsInteger
GetResultValueAsString
NextResult
ResultSetTerm
ResultSetValue