CREATE CURSOR t0(序号 i,姓名 C(10),其他 C(10))
INSERT INTO T0(序号,姓名,其他) VALUES(1,'A1','其他1')
INSERT INTO T0(序号,姓名,其他) VALUES(2,'A2','其他2')
INSERT INTO T0(序号,姓名,其他) VALUES(3,'A3','其他3')
INSERT INTO T0(序号,姓名,其他) VALUES(4,'A4','其他4')
INSERT INTO T0(序号,姓名,其他) VALUES(5,'A5','其他5')
INSERT INTO T0(序号,姓名,其他) VALUES(6,'A6','其他6')
BROWSE
swap(2,5,'t0')
BROWSE
FUNCTION swap(n1,n2,dbf1)
SELECT * FROM (dbf1) WHERE 序号 = n1 INTO ARRAY a1
SELECT * FROM (dbf1) WHERE 序号 = n2 INTO ARRAY a2
SELECT (dbf1)
GO n1
GATHER FROM A2
REPLACE 序号 WITH n1
GO n2
GATHER FROM A1
REPLACE 序号 WITH n2
ENDFUNC
INSERT INTO T0(序号,姓名,其他) VALUES(1,'A1','其他1')
INSERT INTO T0(序号,姓名,其他) VALUES(2,'A2','其他2')
INSERT INTO T0(序号,姓名,其他) VALUES(3,'A3','其他3')
INSERT INTO T0(序号,姓名,其他) VALUES(4,'A4','其他4')
INSERT INTO T0(序号,姓名,其他) VALUES(5,'A5','其他5')
INSERT INTO T0(序号,姓名,其他) VALUES(6,'A6','其他6')
BROWSE
swap(2,5,'t0')
BROWSE
FUNCTION swap(n1,n2,dbf1)
SELECT * FROM (dbf1) WHERE 序号 = n1 INTO ARRAY a1
SELECT * FROM (dbf1) WHERE 序号 = n2 INTO ARRAY a2
SELECT (dbf1)
GO n1
GATHER FROM A2
REPLACE 序号 WITH n1
GO n2
GATHER FROM A1
REPLACE 序号 WITH n2
ENDFUNC