简体   繁体   English

ORA-01036中的Delphi7主详细关系查询结果

[英]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(分别称为AB ),两个TDataSetProviders( dspAdspB ),两个TClientDataSets( cdsAcdsB ),两个TDataSources( dsAdsB )以及两个DBGrid( gridAgridB )。 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. 字段aB的字段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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM