[英]Delphi7 master detail relations query results in ORA-01036
I'm using Delphi7, Devart's dbExpress driver 4.70. 我正在使用Devart的dbExpress驱动程序4.70 Delphi7。
I drop two TSQLTables (call them A
and B
), two TDataSetProviders ( dspA
and dspB
), two TClientDataSets ( cdsA
and cdsB
), two TDataSources ( dsA
and dsB
) and two DBGrids ( gridA
and gridB
). 我删除了两个TSQLTables(分别称为
A
和B
),两个TDataSetProviders( dspA
和dspB
),两个TClientDataSets( cdsA
和cdsB
),两个TDataSources( dsA
和dsB
)以及两个DBGrid( gridA
和gridB
)。 Everything is set fine. 一切都很好。 If I set
cdsA.Active
to true I can see the data in gridA
. 如果将
cdsA.Active
设置为true,则可以在gridA
看到数据。 The same per cdsB
. 每个
cdsB
相同。
Now I want to implement the relation 现在我要实现关系
A JOIN B ON a = b.
The field a
is the true A
's foreing key referred by B
's field b
and b
is B
's primary key too. 字段
a
是B
的字段b
引用的真实A
的前键,并且b
也是B
的主键。 I set the stuff as follow (I use graphic tools): 我将内容设置如下(我使用图形工具):
cdsB.MasterSource := dsA;
cdsB.MasterFields := a;
cdsB.IndexFieldNames := b;
When I do cdsB.Open
, I got this error: 当我执行
cdsB.Open
,出现以下错误:
ORA-01036: illegal variable name/number".
ORA-01036:非法的变量名称/编号”。
The field a
value is always null
in table A (there is no data). 表A中的字段
a
值始终为null
(没有数据)。 TSQLMonitor reports the following queries: Execute: select * from A
TSQLMonitor报告以下查询:
Execute: select * from A
...
Execute: select * from ENTI where (b is NULL)
:1 (Number,IN) = <NULL>
What did I miss, and how can this be fixed? 我错过了什么,如何解决?
When using Datasnap, you should set the M/D relationship on the source datasets, not the client ones. 使用Datasnap时,应该在源数据集而不是客户端数据集上设置M / D关系。 It will create a "dataset field" in the master client dataset.
它将在主客户端数据集中创建一个“数据集字段”。 You then assign this field to the child client dataset.
然后,您将此字段分配给子客户端数据集。 This approach is also more perfomant.
这种方法也更有效。
Anyway it should work as well, it looks there is something wrong with your SQL. 无论如何,它也应该正常工作,看起来您的SQL出了点问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.