Show TOC

rs_writetextLocate this document in the navigation structure

Modifies <text>, <unitext>, or <image> data in a replicate database.

Examples
Example 1

Creates an rs_writetext function string that uses the RPC method to update the <copy> column in the <blurbs> table.

create function string
   blurbs_rep.rs_writetext;copy
 for gw_function_class
 output rpc
 'execute update_blurbs_copy
   @copy_chunk = ?copy!new?,
   @au_id = ?au_id!new?,
   @last_chunk = ?rs_last_text_chunk!sys?,
   @writetext_log = ?rs_writetext_log!sys?'
Example 2

Creates an rs_writetext function string that uses the writetext method to update the <copy> column. Replication Server modifies the <copy> column by using the I/O descriptor returned by the execution of the rs_get_textptr function for the <copy> column.

create function string
   blurbs_rep.rs_writetext;copy
 for rs_sqlserver2_function_class
 output writetext
 use primary log
For example, if you have a function string for rs_get_textptr, then the rs_writetext function modifies the <repcopy> column in the <blurbs> table, as follows:
create function string
   blurbs_rep.rs_get_textptr;copy
 for sqlserver2_function_class
 output language
 'select repcopy from blurbs
  where au_id = ?au_id!new?'
Example 3
Creates an rs_writetext function string that uses the none method to specify that the <copy> column should not be updated.
create function string
   blurbs_rep.rs_writetext;copy
 for rs_sqlserver2_function_class
 output none
Usage
  • rs_writetext has replication definition scope.

  • For each replicated <text>, <unitext>, or <image> column in a replication definition, Replication Server generates an rs_writetext function string for the <rs_sqlserver_function_class> and <rs_default_function_class> classes when you create the replication definition.

  • If you use a user-created function-string class, create an rs_writetext function string for each replicated <text>, <unitext>, or <image> column included in the replication definition.

  • Create or customize an rs_writetext function string at the Replication Server where you created the replication definition.

  • Replication Server supports three output formats for creating an rs_writetext function string: RPC, writetext, and none.

  • ExpressConnect for Oracle and ExpressConnect for HANA DB do not use LOB pointers to manage LOB data. Consequently, the Replication Server system functions used to managing LOB pointers are unavailable to ExpressConnect for Oracle and ExpressConnect for HANA DB. These functions–which include rs_get_textptr, rs_textptr_init, and rs_writetext–are visible to ExpressConnect, but their use is ignored by Replication Server.

Using the RPC Method

With the RPC method for creating an rs_writetext function string, Replication Server executes a remote procedure call repeatedly, providing up to 255 bytes of the <text>, <unitext>, or <image> value on each procedure execution.

The data is passed in the RPC in a <varchar> parameter for <text> or <unitext> data or in a <varbinary> parameter for <image> data. Replication Server ensures that the data chunks are partitioned on character boundaries for <text> or <unitext> columns. If a 1-byte character set is in use, the data is sent in 255-byte chunks.

Each time Replication Server executes the RPC, it sets the <rs_last_text_chunk> system variable, an <int>, to 0 if there is more data to follow or to 1 if this is the last RPC execution for this <text> column.
  • Another <int> system variable, <rs_writetext_log>, is set to 1 if the writetext logging option was used in the primary database or 0 if the logging option was not used in the primary database.

  • The values of other columns in the data row can be accessed by using the <new> or <old> modifier. If you used the Transact-SQL insert command at the primary database, you must use the <new> modifier.

  • Use the <text_status> modifier to retrieve the status of a <text>, <unitext>, or <image> column. For a description of the <text_status> modifier, see "rs_datarow_for_writetext."

Using the writetext Method

The writetext method for creating an rs_writetext function string provides the options shown in the following table to specify the logging behavior in the replicate database.

Table 1: writetext Logging Options

Logging Option

Description

use primary log

Log the data in the replicate database transaction log if the logging option was specified in the primary database transaction log. Do not log if logging is not specified in the primary database transaction log.

with log

Log the data in the replicate database transaction log.

no log

Do not log the data in the replicate database transaction log.

The default function string for <rs_sqlserver_function_class> uses the use primary log option.

Using the none Method

The none output template option for rs_writetext function strings instructs Replication Server not to use the Client-Library function ct_send_data to update a <text>, <unitext>, or <image> column value. This option provides necessary flexibility for using <text>, <unitext>, or <image> columns in a heterogeneous environment.

See the Replication Server Administration Guide Volume 2 for more information.