Qore Programming Language Reference Manual 0.8.8

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
Functions
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...
any | Qore::cx_value (string key)
| Returns the current value of the given column while iterating a context statement. More...

## Detailed Description

## Function Documentation

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

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

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

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

any 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)) {
  my any $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