Copy_Row subroutine

Copies a row or a group of rows from one table to another.

Copy_Row(scrtablename, scrkeylist, desttablename, destkeylist, overwriteflag, lockflag, deleteSource)

The Copy_Row subroutine has the following parameters.

ParameterDescription
scrtablenameThe name of the table that contains the row or rows to be copied.
scrkeylistA key or list of keys to copy from scrtablename to desttablename. A one-to-one correspondence must exist between scrkeylist and destkeylist.

Note: If more than one rows are to be copied, separate the keys with field marks. See the Example 2 below.
desttablenameSpecifies the name of the table into which the rows are copied. If null, then scrtablename is used.
destkeylistA key or list of keys to copy from scrtablename to the keys specified in destkeylist in the desttablename table. A one-to-one correspondence must exist between destkeylist and scrkeylist. If null, then scrkeylist is used.
overwriteflagSpecifies whether or not rows copied to a new table overwrite an existing row. The default value is 0 (no overwrites).

Value Description
0 - Prevents overwriting an existing row (default).
1 - Only replace an existing row. If destination row does not exist, then skip this row.
2 - Write this row, unconditionally. If the destination row exists, overwrite it.
lockflagSpecifies whether rows are locked during the copy process. The default is 0 (no locking).

Value Description
0 - No locking during the copy process.
1 - Lock the source & destination rows during the copy process.
deleteSourceSpecifies whether the source rows are deleted during the copy process. The default is 0 (no deletion).

Value Description
0 - The source rows are not deleted after copying.
1 - The source rows are deleted after copying.

Notes:Although the Copy_Row subroutine can be called from a BASIC+ program, it is preferable to use the Read and Write statements instead.
Set_Status/Get_Status Error handling should be used when programmatically executing the Copy_Row routine.|

From the System Monitor:

This command line example shows how to copy the row 5*5 to the key 5*20 in the CAR_PARTS table, overwriting any existing destination row:

run Copy_Row "CAR_PARTS", "5*5", "", "5*20", "2"

Example 2 * Copying Multiple Rows from BASIC+ Program

* Copy rows with keys '1' and '2' from CUSTOMERS table to the CUSTOMERS_BACKUP table.

declare subroutine Copy_Row, Set_Status, FsMsg
declare function Get_Status

row_list = '1': @fm : '2'

Set_Status(0)

Copy_Row( "CUSTOMERS", row_list, "CUSTOMERS_BACKUP", row_list , 0, 0, 0 )

if Get_Status( errCodes ) then

   FsMsg( errCodes )

end

 
 
  • guides/programming/programmers_reference_manual/copy_row.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1