B
bfox
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.SpeedButton7Click(Sender: TObject);
begin
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add ('UPDATE person SET fcode = (SELECT fcode FROM person WHERE ');
adoquery1.sql.add ('pcode = (SELECT MAX(pcode)FROM person WHERE pcode IN ');
adoquery1.sql.add ('(SELECT pcode FROM person WHERE pname =name)))WHERE ');
adoquery1.sql.add ('fcode = (SELECT fcode FROM person WHERE pcode = : fcode) ');
adoquery1.sql.add ('AND pcode <> : pcode ');
adoquery1.open;
end;
运行后报错
project edit2.exe raised exception class eoleexception with message 'the application has improperly defined a parameter object'.process stopped .use step or run to continue.
这个SQL应该没有问题,因为我在sql 7的 query analys 里面试过
简单介绍如下
有一个person 表,表里有pcode(编号) ,pname(名字), fcode(家庭编号)几个字段
如果fcode 相同就说明是一个家庭的,
现在由于操作失误,导致录入了许多姓名相同的人(pname 相同)
现在要把 相同的人删除,但是首先要把和他fcode 相同的纪录的fcode 改到他姓名(pname)相同的人名下
说的可能不够清楚,但是结合sql 语句应该能看懂了
UPDATE person
SET fcode =
(SELECT fcode
FROM person
WHERE pcode =
(SELECT MAX(pcode)
FROM person
WHERE pcode IN
(SELECT pcode
FROM person
WHERE pname = : pname)))
WHERE fcode =
(SELECT fcode
FROM person
WHERE pcode = : fcode) AND pcode <> : pcode
谁能告诉我为什么操作会报错呢??
begin
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add ('UPDATE person SET fcode = (SELECT fcode FROM person WHERE ');
adoquery1.sql.add ('pcode = (SELECT MAX(pcode)FROM person WHERE pcode IN ');
adoquery1.sql.add ('(SELECT pcode FROM person WHERE pname =name)))WHERE ');
adoquery1.sql.add ('fcode = (SELECT fcode FROM person WHERE pcode = : fcode) ');
adoquery1.sql.add ('AND pcode <> : pcode ');
adoquery1.open;
end;
运行后报错
project edit2.exe raised exception class eoleexception with message 'the application has improperly defined a parameter object'.process stopped .use step or run to continue.
这个SQL应该没有问题,因为我在sql 7的 query analys 里面试过
简单介绍如下
有一个person 表,表里有pcode(编号) ,pname(名字), fcode(家庭编号)几个字段
如果fcode 相同就说明是一个家庭的,
现在由于操作失误,导致录入了许多姓名相同的人(pname 相同)
现在要把 相同的人删除,但是首先要把和他fcode 相同的纪录的fcode 改到他姓名(pname)相同的人名下
说的可能不够清楚,但是结合sql 语句应该能看懂了
UPDATE person
SET fcode =
(SELECT fcode
FROM person
WHERE pcode =
(SELECT MAX(pcode)
FROM person
WHERE pcode IN
(SELECT pcode
FROM person
WHERE pname = : pname)))
WHERE fcode =
(SELECT fcode
FROM person
WHERE pcode = : fcode) AND pcode <> : pcode
谁能告诉我为什么操作会报错呢??