Description
Copies a row or a group of rows from one table to another.
Syntax
Copy_Row (scrtablename, scrkeylist, desttablename, destkeylist, overwriteflag, lockflag, deleteSource)
Parameters
The Copy_Row subroutine has the following parameters.
Parameter | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
scrtablename | The name of the table that contains the row or rows to be copied. | ||||||||
scrkeylist | A 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. | ||||||||
desttablename | Specifies the name of the table into which the rows are copied. If null, then scrtablename is used. | ||||||||
destkeylist | A 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. | ||||||||
overwriteflag | Specifies whether or not rows copied to a new table overwrite an existing row. The default value is 0 (no overwrites).
| ||||||||
lockflag | Specifies whether rows are locked during the copy process. The default is 0 (no locking).
| ||||||||
deleteSource | Specifies whether the source rows are deleted during the copy process. The default is 0 (no deletion).
|
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.
See also
Copy_OS_To_Row, Copy_Row_To_OS, Delete_Row
Example
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