CDS: How to refresh data from server

CDS: How to refresh data from server

Post by Bernhard B » Fri, 12 Aug 2005 20:28:33


Hi all,

I am sure I am just missing something very stupid...

My application (D7 Ent, IB7.5, IBX) uses several CDS for displaying data
( IBquery->datasetprovider->Clientdataset->datasource->DBGrid with
transaction1).

In some cases, I insert records to the underlying tables with a separate
IBquery (with transaction2). My question now is, how can I force the CDS
to get the fresh data from the server after committing transaction2?
I tried a lot of commands with the CDS (.refresh, active = true/false
etc.), but nothing works for me.
The only way I found out ist to disconnect the DB and reconnect, but I am
sure there must be something else.



Example of what I am trying:


Query:

select t.typfamilie, t.baureihen, p.last_min,p.last_max , p.anlage_id
from PRODUKTE p left join
typfamilien t on p.typfamilie_id=t.id
where p.ANLAGE_ID = :NEWANLAGE_ID


Table:
CREATE TABLE PRODUKTE
(
ID INTEGER NOT NULL,
TYPFAMILIE_ID INTEGER NOT NULL,
LAST_MIN DOUBLE PRECISION,
LAST_MAX DOUBLE PRECISION,
ANLAGE_ID INTEGER NOT NULL,
CONSTRAINT PK_PRODUKTE PRIMARY KEY (ID)
)


CREATE TABLE TYPFAMILIEN
(
ID INTEGER NOT NULL,
TYPFAMILIE VARCHAR( 64) NOT NULL COLLATE NONE,
BAUREIHEN VARCHAR( 128) COLLATE NONE,
LASTEINHEIT VARCHAR( 64) COLLATE NONE,
CONSTRAINT PK_TYPFAMILIEN PRIMARY KEY (ID)
)




So the CDS has a mastersource (masterfield is ANLAGE_ID) to fill the
param.

select * from ANLAGE order by anl_id asc

from the table
CREATE TABLE ANLAGE
(
ID INTEGER NOT NULL,
ANL_NAME VARCHAR( 128) NOT NULL COLLATE
NONE,
ANL_ID CHAR( 8) NOT NULL COLLATE
NONE,
KOSTENSTELLE VARCHAR( 4) COLLATE NONE,
STANDORT VARCHAR( 32) COLLATE NONE,
VERANTWORTLICH VARCHAR( 128) COLLATE NONE,
ANZAHL_AUFNEHMER INTEGER,
DURCHSATZ VARCHAR( 128) COLLATE NONE,
DURCHSATZMIN VARCHAR( 128) COLLATE NONE,
DURCHSATZMAX VARCHAR( 128) COLLATE NONE,
WIEDERBESCHAFFUNGSWERT VARCHAR( 12) COLLATE NONE,
CONSTRAINT PK_ANLAGE PRIMARY KEY (ID)
)


Now, I am INSERTing into table PRODUKTE and want my CDS to display the
new record also. This INSERT is done in a separate transaction which I
start/commit explicitly. The CDSs use another transaction which is
controlled automatically.

Thanks for anny hints!

Bernhard
 
 
 

CDS: How to refresh data from server

Post by Bill Tod » Fri, 12 Aug 2005 22:59:24

It sounds like you are starting a transaction for the CDS and leaving
the transaction active instead of letting the CDS start and end its
transaction automatically. If you are starting the transaction used by
the CDS manually, keeping it active and using snapshot transaction
isolation you will not see changes made by other users for the life of
the transaction.

--
Bill Todd (TeamB)

 
 
 

CDS: How to refresh data from server

Post by Bernhard B » Sat, 13 Aug 2005 17:22:36


Hi,

thanks for the reply.
I am thinking in almost the same direction. But my CDS and my Query have
separate transactions. I start and commit the transaction for my insert
manually, and leave the transaction for the CDS in automatic mode
(allowAutoStart=true), actually it is never touched in my source code. Can
there be any other reason for the CDS-transaction to stay active?

But I think it is rather the question how to force the CDS to get fresh
data from the server. I can do the same insert using IBConsole. After
committing in IBConsole, how can I tell my CDS to refresh his data, besides
dis/reconnecting the database? Transaction for the CDS is set to
read_committed, rec_version, nowait.

Bernhard
 
 
 

CDS: How to refresh data from server

Post by Bill Tod » Sat, 13 Aug 2005 22:36:59

Are you sure that you have the AutoStopAction property of the
IBTransaction for the CDS set to saCommit? Not having AutoStopAction
set would cause the problem you describe because the transaction would
never be committed.

--
Bill Todd (TeamB)