Home How To Online Documentation Support Download Order
 

 

 

SACommand
SAConnection
SAException
SAField
SAParam

SAString
SADateTime
SANumeric
SAInterval

Enums and Typedefs

  

Usage

Class Members

Examples

SACommand::operator <<

SACommand &operator << ( const SANull &null ) ;
throw (SAException);

SACommand &operator << ( const SAPos &pos );
throw (SAException);

SACommand &operator << ( bool &Value );
throw (SAException);

SACommand &operator << ( short &Value );
throw (SAException);

SACommand &operator << ( long &Value );
throw (SAException);

SACommand &operator << ( double &Value );
throw (SAException);

SACommand &operator << ( const SANumeric &Value );
throw (SAException);

SACommand &operator << ( const SADateTime & Value );
throw (SAException);

SACommand &operator << (const SAChar *Value );
throw (SAException);

SACommand &operator << ( const SAString &Value );
throw (SAException);

SACommand &operator << ( const SABytes &Value );
throw (SAException);

SACommand &operator << ( const SALongBinary &LongValue );
throw (SAException);

SACommand &operator << ( const SALongChar &LongValue );
throw (SAException);

SACommand &operator << ( const SABlob & LobValue ) ;
throw (SAException);

SACommand &operator << ( const SAClob &LobValue ) ;
throw (SAException);

SACommand &operator << ( const SAValueRead &Value ) ;
throw (SAException);

Binds input variables.

Parameters

Value .    A value of an input variable.

LongValue.    A reference to an aiding object representing a value of a long input variable or a callback function which will be used for getting the long value.

LobValue.    A reference to an aiding object representing a value of a Lob input variable or a callback function which will be used for getting the Lob value.

pos.    A reference to the SAPos object which represents the position of input parameter in the command.

Remarks

This operator is used for associating data objects to the command object. Every command object maintains an internal heterogeneous array of parameter objects - this operator assigns values to parameter objects from this array. 

Because of the operator returns a reference to a SACommand object you can chain the operator e.g. cmd << 3 << 2.5 << "Istanbul";

By default the sequence of values corresponds to the numbers of parameters in a command text.
E.g. (cmd is a SACommnad object)

  1. Select a from b where c= :1 and d= :2
    cmd << 5 << "qwerty";
    binds 5 to c(:1) and qwerty to d(:2) parameters.

  2. Select a from b where c= :2 and d= :1
    cmd << 5 << "qwerty";
    binds 5 to d(:1) and qwerty to c(:2) parameters (see the difference with example 1).

  3. Select a from b where c= :1 and d= :3
    cmd << 5 << "qwerty";
    causes an error (throws an exception) because << "qwerty" tries to bind :2 parameter and our command does not have such.

If you want to assign null value to an input variable you have to include SANull object in the chain of bind operators in place of null value.

E.g. (cmd is a SACommnad object)

  1. Select a from b where c= :1 and d= :2
    cmd << 5 << SANull();
    binds 5 to c(:1) and null to d(:2) parameters.

If you want to bind a parameter by name or change the order of binding variables you have to include a SAPos object before the value in the chain of bind operators to prepare the required parameter position for the next bind.

E.g. (cmd is a SACommnad object)

  1. Select a from b where c = :1 and d = :2
    cmd << SAPos(2) << 5 << SAPos(1) << "qwerty";
    first binds d(:2) parameter with value of 5, then c(:1) with value of qwerty.
     
  2. Select a from b where c = :c_bind and d = :d_bind
    cmd << SAPos("c_bind") << 5 << SAPos("d_bind") << "qwerty";
    is the right sequence to be used.

Values for the input parameters can also be assigned to SAParam object.

Syntax SACommand &operator << ( const SAValueRead &Value ); allows to set input variable's value from existing SAParam or SAField object. 

Server specific notes

Binding Lob(CLob, BLob) data when working with Oracle server has some differences from others. It's necessary for a name of bind variable to be the same as the column name it associated with.

Ex.:     Update TEST set FBLOB = :fblob where FKEY = 'KEY'

Therefore, it's impossible to bind Lob(CLob, BLob) data to Oracle database by position.

See also

CreateParam, Param, ParamByIndex, ParamCount

SAParam, SAField

Error handling

Problems and Questions

If you haven't found the answer to your questions or have some problems on using the Library, please, send e-mail to howto@sqlapi.com.