Context Functions

## Functions

bool | Qore::cx_first ()
| Returns True if currently iterating the first element in a context statement, False if not. More...
bool | Qore::cx_last ()
| Returns True if currently iterating the last element in a context statement, False if not. More...
int | Qore::cx_pos ()
| Returns the current row number within the active context statement (starting from 0) More...
int | Qore::cx_total ()
| Returns the total number of rows within the active context statement. More...
auto | Qore::cx_value (string key)
| Returns the current value of the given column while iterating a context statement. More...

## Detailed Description

## Function Documentation

## cx_first()

bool Qore::cx_first | ( |  | ) |

Returns True if currently iterating the first element in a context statement, False if not.

Returns
  True if currently iterating the first element in a context statement, False if not

Code Flags:
  RET_VALUE_ONLY

Example:
  context (ds.select(sql)) {
  if (cx_first())
  print("first row!\n");
  }

Exceptions

  CONTEXT-ERROR | this exception is thrown if called without an active context statement

Since
  Qore 0.8.4

## cx_last()

bool Qore::cx_last | ( |  | ) |

Returns True if currently iterating the last element in a context statement, False if not.

Returns
  True if currently iterating the last element in a context statement, False if not

Code Flags:
  RET_VALUE_ONLY

Example:
  context (ds.select(sql)) {
  if (cx_last())
  print("last row!\n");
  }

Exceptions

  CONTEXT-ERROR | this exception is thrown if called without an active context statement

Since
  Qore 0.8.4

## cx_pos()

int Qore::cx_pos | ( |  | ) |

Returns the current row number within the active context statement (starting from 0)

Returns
  the current row number within the active context statement (starting from 0)

Code Flags:
  RET_VALUE_ONLY

Example:
  context (ds.select(sql)) {
  printf("row %d/%d:\n", cx_pos(), cx_total());
  }

Exceptions

  CONTEXT-ERROR | this exception is thrown if called without an active context statement

Since
  Qore 0.8.4

## cx_total()

int Qore::cx_total | ( |  | ) |

Returns the total number of rows within the active context statement.

Returns
  the total number of rows within the active context statement

Code Flags:
  RET_VALUE_ONLY

Example:
  context (ds.select(sql)) {
  printf("row %d/%d:\n", cx_total(), cx_total());
  }

Exceptions

  CONTEXT-ERROR | this exception is thrown if called without an active context statement

Since
  Qore 0.8.4

## cx_value()

auto Qore::cx_value | ( | string | key | ) |

Returns the current value of the given column while iterating a context statement.

Code Flags:
  RET_VALUE_ONLY

Parameters

  key | the column name to return the value for

Returns
  the current value of the given column while iterating a context statement

Example:
  context (ds.select(sql)) {
  auto val = cx_value("column1");
  }

Exceptions

  CONTEXT-ERROR | this exception is thrown if called without an active context statement
  ENCODING-CONVERSION-ERROR | the given string could not be converted to the default character encoding

Since
  Qore 0.8.4