For the complete documentation index, see llms.txt. This page is also available as Markdown.

ExecuteQuery

Query data using PostgreSQL. https://tasks.frends.com/tasks/frends-tasks/Frends.PostgreSQL.ExecuteQuery

Task version: 2.0.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Task Parameters

Name
Description

Query : String

Query.

Note: Normal query requires double quotes around Column and 2 single quotes around Value.

Default: SELECT * FROM Users Example: SELECT * FROM Users

Parameters : Parameter[]

Query parameters.

Default: - Example: [{ Name = "Name", Value = "Erik" }, { Name = "Email", Value = "erik.example@foobar.com" }]

🗝ConnectionString : String

Connection string.

Default: - Example: Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

ExecuteType : ExecuteTypes

Specifies how a command string is interpreted.

Auto: Automatically detects if the query returns data (SELECT or RETURNING clause) and uses ExecuteReader, otherwise uses NonQuery.

ExecuteReader: Use this to execute queries that return a result set (SELECT or INSERT/UPDATE/DELETE with RETURNING clause).

NonQuery: Use this to execute commands that don't return a result set (INSERT, UPDATE, DELETE without RETURNING). Returns the number of affected rows.

Possible values:

  • Auto: Specifies how a command string is interpreted.

Auto: Automatically detects if the query returns data (SELECT or RETURNING clause) and uses ExecuteReader, otherwise uses NonQuery.

ExecuteReader: Use this to execute queries that return a result set (SELECT or INSERT/UPDATE/DELETE with RETURNING clause).

NonQuery: Use this to execute commands that don't return a result set (INSERT, UPDATE, DELETE without RETURNING). Returns the number of affected rows.

  • NonQuery: Specifies how a command string is interpreted.

Auto: Automatically detects if the query returns data (SELECT or RETURNING clause) and uses ExecuteReader, otherwise uses NonQuery.

ExecuteReader: Use this to execute queries that return a result set (SELECT or INSERT/UPDATE/DELETE with RETURNING clause).

NonQuery: Use this to execute commands that don't return a result set (INSERT, UPDATE, DELETE without RETURNING). Returns the number of affected rows.

  • ExecuteReader: Specifies how a command string is interpreted.

Auto: Automatically detects if the query returns data (SELECT or RETURNING clause) and uses ExecuteReader, otherwise uses NonQuery.

ExecuteReader: Use this to execute queries that return a result set (SELECT or INSERT/UPDATE/DELETE with RETURNING clause).

NonQuery: Use this to execute commands that don't return a result set (INSERT, UPDATE, DELETE without RETURNING). Returns the number of affected rows.

Default: 0 Example: ExecuteTypes.Auto

Task Result

Name
Description

QueryResult : Object

Result of the query. Example: [{ "id": 123, "Name": "Matti" }, { "id": 124, "Name": "Teppo" }]

Task Changelog

Changelog for Task Frends.PostgreSQL.ExecuteQuery.

[2.0.0] - 2025-12-02

Added

  • Added ExecuteType parameter to Input class with options: Auto (default), ExecuteReader, and NonQuery.

  • Added support for INSERT/UPDATE/DELETE statements with RETURNING clause to return actual column values instead of just AffectedRows.

  • Added ExecuteTypes enum to provide explicit control over query execution behavior.

Changed

  • Modified query execution logic to use ExecuteType parameter instead of simple string parsing.

  • Auto mode now checks reader.FieldCount to determine if data is returned, providing more reliable detection than keyword matching.

  • Transaction handling now only applies to write operations (Auto and NonQuery modes), not read-only queries (ExecuteReader mode).

Fixed

  • Fixed issue where INSERT/UPDATE/DELETE with RETURNING clause only returned AffectedRows instead of the actual returned column values.

[1.1.0] - 2024-08-23

Changed

  • Updated the Newtonsoft.Json package to version 13.0.3 and the Npgsql package to version 8.0.3.

[1.0.1] - 2023-02-02

Fixed

  • Fixed memory leak issue by adding cleanup method to the main class.

[1.0.0] - 2022-10-13

Added

  • Initial implementation

Last updated

Was this helpful?