RowsCopy

Description

Copies a range of rows from one DataWindow control (or DataStore object) to another, or from one buffer to another within a single DataWindow control (or DataStore).

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object


Syntax

PowerBuilder

integer dwcontrol.RowsCopy ( long startrow, long endrow, 
   DWBuffer copybuffer, datawindow targetdw, long beforerow,
   DWBuffer targetbuffer)
integer dwcontrol.RowsCopy ( long startrow, long endrow, 
   DWBuffer copybuffer, datastore targetdw, long beforerow, 
   DWBuffer targetbuffer )
integer dwcontrol.RowsCopy ( long startrow, long endrow, 
   DWBuffer copybuffer, datawindowchild targetdw, long beforerow,
   DWBuffer targetbuffer )

Argument

Description

dwcontrol

The name of the DataWindow control, DataStore, or child DataWindow from which you want to copy rows.

startrow

The number of the first row you want to copy.

endrow

The number of the last row you want to copy.

copybuffer

A value of the dwBuffer enumerated datatype identifying the DataWindow buffer from which you want to copy rows.

For a list of valid values, see DWBuffer.

targetdw

A reference to the DataWindow control or DataStore object to which you want to copy the rows. Targetdw can be the same DataWindow (or DataStore) or another DataWindow (or DataStore).

beforerow

The number of the row before which you want to insert the copied rows. To insert after the last row, use any value that is greater than the number of existing rows.

targetbuffer

A value of the dwBuffer enumerated datatype identifying the target DataWindow buffer for the copied rows.

For a list of valid values, see DWBuffer.


Return value

Returns 1 if it succeeds and -1 if an error occurs.

If any argument's value is null, in PowerBuilder and JavaScript the method returns null.

Usage

When you use the RowsCopy method, the status of the rows that are copied to the primary buffer is NewModified!. If you issue an update request, PowerBuilder sends SQL INSERT statements to the DBMS for the new rows.

When you use RowsCopy, data is not automatically retrieved for drop-down DataWindows in the target DataWindow or DataStore, as it is when you call InsertRow. You must explicitly call Retrieve for child DataWindows in the target.

When you use RowsCopy or RowsMove to populate another DataWindow, the copied data is not automatically processed by filters or sort criteria in effect on the target DataWindow. You might be required to call the Filter, GroupCalc, or Sort methods to properly process the data.

Uses for RowsCopy include:

  • Making copies of one or more rows so that the users can create new rows based on existing data

  • Printing a range of rows by copying selected rows to another DataWindow and printing the second DataWindow

Buffer manipulation and query mode

A DataWindow cannot be in query mode when you call the RowsCopy method.

Examples

This statement copies all the rows starting with the current row in dw_1 to the beginning of the primary buffer in dw_2:

dw_1.RowsCopy(dw_1.GetRow(), &
      dw_1.RowCount(), Primary!, dw_2, 1, Primary!)

This example copies all the rows starting with the current row in dw_1 to the beginning of the primary buffer in the drop-down DataWindow state_id in dw_3:

datawindowchild dwc
dw_3.GetChild("state_id", dwc)
dw_1.RowsCopy(dw_1.GetRow(), &
      dw_1.RowCount(), Primary!, dwc, 1, Primary!)

This example copies all the rows starting with the current row in dw_1 to the beginning of the primary buffer in the nested report d_employee:

datawindowchild dwc
dw_composite.GetChild("d_employee", dwc)
dw_1.RowsCopy(dw_1.GetRow(), &
      dw_1.RowCount(), Primary!, dwc, 1, Primary!)

See also

RowsDiscard

RowsMove