A Varchar object, like a string, will expand as needed to accommodate any value assigned to it. However, this does not include the receipt of an input value from the OCI. The maximum size will limit the size of output data, since the OCI is not capable of expanding the storage area provided for it. Be sure that Varchar objects bound to output placeholders or SELECT list columns are large enough to accommodate the returned value. Otherwise, Error will be thrown.
Figure 2-2. class Varchar
namespace Oracle
{
class Varchar: public Nullable
{
public:
// constructors/destructor
Varchar();
Varchar(const int);
Varchar(const char*);
Varchar(const string&);
Varchar(const Varchar&);
virtual ~Varchar();
// accessors
virtual string str() const;
virtual string str(const string&) const;
virtual string str(const string&, const Format&) const;
virtual string sql_str() const;
virtual long lng() const;
virtual long lng(const long) const;
virtual double dbl() const;
virtual double dbl(const double) const;
virtual int sqlt() const;
virtual int maxsize() const;
// operators
Varchar& operator=(const char*);
Varchar& operator=(const string&);
Varchar& operator=(const Varchar&);
Varchar& operator=(const long);
Varchar& operator=(const double);
protected:
// implementors
virtual void* data() const;
};
ostream& operator<<(ostream&, const Varchar&);
const bool operator==(const Varchar&, const Varchar&);
}Varchar(void);
Varchar(const int initial_size);
Varchar(const char* initial_value);
Varchar(const string& initial_value);
Varchar(const Varchar& initial_value);
Varchar(const Nullable& initial_value);
A Varchar object may be initialized to a string, another Nullable-derived object, or as an empty string with a specified maximum size.
Varchar& operator=(const char* new_value);
Varchar& operator=(const string& new_value);
Varchar& operator=(const Varchar& new_value);
Varchar& operator=(const Nullable& new_value);
Varchar& operator=(const long new_value);
Varchar& operator=(const double new_value);
Strings and other Nullable-derived objects may be assigned to a Varchar object. When a Nullable object is assigned, the object is set to null.