1

I'm using Delphi7, Devart's dbExpress driver 4.70.

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). Everything is set fine. If I set cdsA.Active to true I can see the data in gridA. The same per 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. 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:

ORA-01036: illegal variable name/number".

The field a value is always null in table A (there is no data). TSQLMonitor reports the following queries: 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?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Francesco
  • 1,742
  • 5
  • 44
  • 78
  • 4
    Edit your question to include the full SQL statement you're executing. – p.campbell Nov 24 '11 at 20:42
  • cdsA is open before you open B? – Tony Hopkinson Nov 24 '11 at 23:00
  • Since you're using the designer, double clicking on the MasterFields property in the Object Inspector should launch the ['Field Link Designer'](http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/fieldlinkdesigner_xml.html). Also see: [Making the Table a Detail of Another Dataset](http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/5datasetmakingthetableadetailofanotherdataset_xml.html) – Sertac Akyuz Nov 25 '11 at 00:30
  • @TonyHopkinson, yes. I open cdsA first, then cdsB. – Francesco Nov 25 '11 at 11:48
  • I substitute `TSQLTable B` with `TSQLQuery B`. I set `B` statement as `select * from B where b=:b`. `B.IndexFieldNames`, `B.MasterFields` and `B.MasterSource` remain the same. Well, if I use `TSQLQuery` instead of `TSQLTable` everything work fine. That's weird. – Francesco Nov 28 '11 at 14:40

1 Answers1

0

When using Datasnap, you should set the M/D relationship on the source datasets, not the client ones. 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.