Qore pgsql Module: PostgreSQL Functions

Qore pgsql Module 2.3

- Main Page
- Modules
- Namespaces

All Namespaces Functions Variables Groups
Functions
PostgreSQL Functions

## Functions
hash | Qore::Pgsql::pgsql_bind (softint type, any value)
| Creates a hash data structure understood by the pgsql DBI driver when binding values in SQL queries that allows programmers to directly specify the PostgreSQL data type for the bind. More...

## Detailed Description

## Function Documentation

hash Qore::Pgsql::pgsql_bind | ( | softint | type,
|  | any | value
| ) |  |

Creates a hash data structure understood by the pgsql DBI driver when binding values in SQL queries that allows programmers to directly specify the PostgreSQL data type for the bind.

Use the Type Constants for pgsql_bind() to specify the PostgreSQL data type for the bind. If the value to bind is `NOTHING` or `NULL`, a `NULL` will be bound as the value, regardless of the PostgreSQL type code provided as the first argument

Code Flags:
  RET_VALUE_ONLY

Parameters

  type | the type code for the PostgreSQL type to bind
  value | the value to bind

Returns
  The hash returned by the function encodes the desired PostgreSQL type for the bind and the value for binding in the `"^pgtype^"` and `"^value^"` keys

Example:
  # we use pgsql_bind() to bind a money type by value, otherwise the server would raise an error
  my float $amount = 400.56;
  my *hash $results = $db.select("select * from table where amount > %v", pgsql_bind(PG_TYPE_CASH, $amount));

Exceptions

  PGSQL-BIND-ERROR | if the type argument is 0 this exception is raised