interface XParameters in module com::sun::star::sdbc::

(Global Index)

Syntax

interface XParameters : com::sun::star::uno::XInterface ;

Description

is used for parameter setting, commonly implemented in conjunction with PreparedStatements.

Note: The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type Integer, then the method XParameters::setInt() should be used.

If arbitrary parameter type conversions are required, the method XParameters::setObject() should be used with a target SQL type.

Example of setting a parameter; con is an active connection.

Example

 pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?")
 pstmt.setDouble(1, 153833.00)
 pstmt.setLong(2, 110592)

See also

XPreparedStatement

Method Summary

setNull sets the designated parameter to SQL NULL.

setObjectNull sets the designated parameter to SQL NULL. This version of setNull should be used for user-named types and REF type parameters. Examples of user-named types include: STRUCT, DISTINCT, OBJECT, and named array types.

setBoolean sets the designated parameter to a boolean value. The driver converts this to a SQL BIT value when it sends it to the database.

setByte sets the designated parameter to a byte value. The driver converts this to a SQL TINYINT value when it sends it to the database.

setShort sets the designated parameter to a short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

setInt sets the designated parameter to a long value. The driver converts this to a SQL INTEGER value when it sends it to the database.

setLong sets the designated parameter to a hyper value. The driver converts this to a SQL BIGINT value when it sends it to the database.

setFloat sets the designated parameter to a float value. The driver converts this to a SQL FLOAT value when it sends it to the database.

setDouble sets the designated parameter to a double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.

setString sets the designated parameter to a string value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHARs) when it sends it to the database.

setBytes sets the designated parameter to a sequence of bytes. The driver converts this to a SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARYs) when it sends it to the database.

setDate sets the designated parameter to a date value. The driver converts this to a SQL DATE value when it sends it to the database.

setTime sets the designated parameter to a time value. The driver converts this to a SQL TIME value when it sends it to the database.

setTimestamp sets the designated parameter to a datetime value. The driver converts this to a SQL TIMESTAMP value when it sends it to the database.

setBinaryStream sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to a LONGVARBINARY or LONGVARCHAR parameter, it may be more practical to send it via an XInputStream . SDBC will read the data from the stream as needed, until it reaches end-of-file.

setCharacterStream sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to a LONGVARCHAR parameter, it may be more practical to send it via a XInputStream . SDBC will read the data from the stream as needed, until it reaches end-of-file.

setObject sets the value of a parameter using an any.

setObjectWithInfo set a value from the Datatype ANY for a parameter.

setRef sets a REF(<structured-type>) parameter.

setBlob sets a BLOB parameter.

setClob sets a CLOB parameter.

setArray sets an Array parameter.

clearParameters clears the current parameter values immediately.

Known Services Which Export this Interface

com::sun::star::sdbc::PreparedStatement

com::sun::star::sdbc::RowSet

Method Details



setNull

Syntax

void setNull (
long parameterIndex,
long sqlType )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to SQL NULL.


setObjectNull

Syntax

void setObjectNull (
long parameterIndex,
long sqlType,
string typeName )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to SQL NULL. This version of setNull should be used for user-named types and REF type parameters. Examples of user-named types include: STRUCT, DISTINCT, OBJECT, and named array types.

Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-named type the name is the type name of the parameter itself. For a REF parameter the name is the type name of the referenced type. If a SDBC driver does not need the type code or type name information, it may ignore it.
Although it is intended for user-named and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-named or REF type, the given typeName is ignored.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter sqlType

the type of the column to set to NULL

Parameter typeName

the name of the type

Throws

SQLException if a database access error occurs.

setBoolean

Syntax

void setBoolean (
long parameterIndex,
boolean x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a boolean value. The driver converts this to a SQL BIT value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setByte

Syntax

void setByte (
long parameterIndex,
byte x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a byte value. The driver converts this to a SQL TINYINT value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setShort

Syntax

void setShort (
long parameterIndex,
short x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setInt

Syntax

void setInt (
long parameterIndex,
long x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a long value. The driver converts this to a SQL INTEGER value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setLong

Syntax

void setLong (
long parameterIndex,
hyper x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a hyper value. The driver converts this to a SQL BIGINT value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setFloat

Syntax

void setFloat (
long parameterIndex,
float x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a float value. The driver converts this to a SQL FLOAT value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setDouble

Syntax

void setDouble (
long parameterIndex,
double x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setString

Syntax

void setString (
long parameterIndex,
string x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a string value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHARs) when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setBytes

Syntax

void setBytes (
long parameterIndex,
sequence< byte > x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a sequence of bytes. The driver converts this to a SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARYs) when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setDate

Syntax

void setDate (
long parameterIndex,
com::sun::star::util::Date x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a date value. The driver converts this to a SQL DATE value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setTime

Syntax

void setTime (
long parameterIndex,
com::sun::star::util::Time x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a time value. The driver converts this to a SQL TIME value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setTimestamp

Syntax

void setTimestamp (
long parameterIndex,
com::sun::star::util::DateTime x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to a datetime value. The driver converts this to a SQL TIMESTAMP value when it sends it to the database.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setBinaryStream

Syntax

void setBinaryStream (
long parameterIndex,
com::sun::star::io::XInputStream x,
long length )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to a LONGVARBINARY or LONGVARCHAR parameter, it may be more practical to send it via an XInputStream . SDBC will read the data from the stream as needed, until it reaches end-of-file.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Parameter length

the number of bytes in the stream

Throws

SQLException if a database access error occurs.

setCharacterStream

Syntax

void setCharacterStream (
long parameterIndex,
com::sun::star::io::XInputStream x,
long length )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to a LONGVARCHAR parameter, it may be more practical to send it via a XInputStream . SDBC will read the data from the stream as needed, until it reaches end-of-file.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Parameter length

the number of characters in the stream

Throws

SQLException if a database access error occurs.

setObject

Syntax

void setObject (
long parameterIndex,
any x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets the value of a parameter using an any.

The given object will be converted to the targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing SQLData), the SDBC driver should call its method writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a service implementing Ref, Blob, Clob, Struct, or Array, the driver should pass it to the database as a value of the corresponding SQL type.

Note that this method may be used to pass database-specific abstract data types.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setObjectWithInfo

Syntax

void setObjectWithInfo (
long parameterIndex,
any x,
long targetSqlType,
long scale )
raises ( com::sun::star::sdbc::SQLException );

Description

set a value from the Datatype ANY for a parameter.

The given object will be converted to the targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing SQLData), the SDBC driver should call its method writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a service implementing Ref, Blob, Clob, Struct, or Array, the driver should pass it to the database as a value of the corresponding SQL type.

Note that this method may be used to pass database-specific abstract data types.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Parameter targetSqlType

the SQL type (as defined in DataType ) to be sent to the database. The scale argument may further qualify this type.

Parameter scale

for DataType::DECIMAL or DataType::NUMERIC types, this is the number of digits after the decimal point. For all other types, this value will be ignored.

Throws

SQLException if a database access error occurs.

setRef

Syntax

void setRef (
long parameterIndex,
com::sun::star::sdbc::XRef x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets a REF(&lt;structured-type&gt;) parameter.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setBlob

Syntax

void setBlob (
long parameterIndex,
com::sun::star::sdbc::XBlob x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets a BLOB parameter.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setClob

Syntax

void setClob (
long parameterIndex,
com::sun::star::sdbc::XClob x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets a CLOB parameter.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

setArray

Syntax

void setArray (
long parameterIndex,
com::sun::star::sdbc::XArray x )
raises ( com::sun::star::sdbc::SQLException );

Description

sets an Array parameter.

Parameter parameterIndex

the first parameter is 1, the second is 2, ...

Parameter x

the parameter value

Throws

SQLException if a database access error occurs.

clearParameters

Syntax

void clearParameters ();
raises ( com::sun::star::sdbc::SQLException );

Description

clears the current parameter values immediately.

In general, parameter values remain in force for repeated use of a Statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling clearParameters.

Throws

SQLException if a database access error occurs.
Top of Page