Qore Programming Language Reference Manual  1.7.0
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");
}
bool cx_first()
Returns True if currently iterating the first element in a context statement, False if not.
nothing print(...)
Outputs a string to standard output with no formatting.
Exceptions
CONTEXT-ERRORthis 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");
}
bool cx_last()
Returns True if currently iterating the last element in a context statement, False if not.
Exceptions
CONTEXT-ERRORthis 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());
}
int cx_total()
Returns the total number of rows within the active context statement.
int cx_pos()
Returns the current row number within the active context statement (starting from 0)
string printf(string fmt,...)
Outputs the string passed to standard output, using the first argument as a format string; does not e...
Exceptions
CONTEXT-ERRORthis 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-ERRORthis 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
keythe 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");
}
auto cx_value(string key)
Returns the current value of the given column while iterating a context statement.
Exceptions
CONTEXT-ERRORthis exception is thrown if called without an active context statement
ENCODING-CONVERSION-ERRORthe given string could not be converted to the default character encoding
Since
Qore 0.8.4