#include <parameter.h>
Public Methods | |
void | to_null (void) |
Sets parameter value to null. | |
parameter & | operator= (Pstr text) |
Sets parameter value to a text. | |
parameter & | operator= (double value) |
Sets parameter value to a double. | |
parameter & | operator= (long value) |
Sets parameter value to a long. | |
parameter & | operator= (const datetime &d) |
Sets parameter value to a date/time. | |
bool | is_null (void) const |
Returns whether parameter is having null value. | |
operator Pstr (void) const | |
Returns parameter value as text. | |
Pstr | as_string (void) const |
Returns parameter value as text. | |
operator double (void) const | |
Returns parameter value as double. | |
double | as_double (void) const |
Returns parameter value as double. | |
operator long (void) const | |
Returns parameter value as long. | |
long | as_long (void) const |
Returns parameter value as long. | |
operator datetime (void) const | |
Returns parameter value as date/time. | |
datetime | as_datetime (void) const |
Returns parameter value as date/time. | |
operator resultset & (void) | |
Returns parameter value as resultset. Internally cached - several calls will return same instance. | |
resultset & | as_resultset (void) |
Returns parameter value as resultset. Internally cached - several calls will return same instance. | |
void | release (void) |
Releases resources allocated for the bound variable (currently does nothing). | |
Friends | |
class | statement |
Parameters (bound variables, named variables) could be used to pass data to Oracle as a part of SQL or PL/SQL statement. Although data could be part of SQL statement's text, for example "insert into TABLE_NAME (ID, NAME) values (1000, 'Your name goes here')", in most cases that data would be dynamic - that is a data, entered by the operator. By using parameters (names prefixed by colons ':') statement will be "insert into TABLE_NAME (ID, NAME) values (:ID, :NAME)" and parameter values will be initialized in run time.
Each parameter is having a data type (text, numeric, cursor, etc.) initialized in the time parameter is bound (statement::bind). Only resultsets (that is "REF CURSOR") are output-only. Text, numeric and date/time parameters could be input/output.
Supported data types are described in oralib::DataTypesEnum and currently are: text, numeric, date/time and resultsets.
parameter class provides C++ friendly interface by exposing overloaded operators, so parameter value could be set simply by using assignment operator and could be read by using C-style type casts. Parameter value can also be read by using methods, such as as_string() and as_long() for example.
to_null() and is_null() are NULL-asignment and NULL-test methods.
Any attempt to read parameter value in type, different than parameter's data type will cause an exception (for example a request for text as numeric). Parameters having NULL value will throw an exception if their value is requested - is_null() should be used when parameter could have NULL value.