 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Vuksa Vladislav Guest
|
Posted: Wed Jan 18, 2006 8:57 am Post subject: RefreshRecord |
|
|
Example:
Select C.CityID, C.Name, S.StateID, S.Name As NameOfState
From City As C
Left Join State As S On (S.StateID=C.StateID)
If I change S.StateID I want to refresh S.Name. I do not want to use requery
'cos it is too slow.
I have tried:
ADO components using properties Recordset.Properties['Resync Command'] and
Recordset.Resync(adAffectCurrent, adResyncAllValues)
TBetterAdo - works with some simple examples, but if I use Join with View
containing SUM it does not work
DbExpress components have implemented RefreshRecord which doesn't work with
Join
I have not succeeded to find any reasonable solution.
|
|
| Back to top |
|
 |
John Herbster Guest
|
Posted: Wed Jan 18, 2006 10:40 am Post subject: Re: RefreshRecord |
|
|
Vuksa,
Please do not multipost. Thank you.
--
JohnH
newsgroup list & guidelines http://info.borland.com/newsgroups/
|
|
| Back to top |
|
 |
Vitali Kalinin Guest
|
Posted: Wed Jan 18, 2006 11:47 am Post subject: Re: RefreshRecord |
|
|
This specific case looks like a proper candidate for using Lookup field.
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Thu Jan 19, 2006 7:33 am Post subject: Re: RefreshRecord |
|
|
OK, but I thought that it concernd all those groups.
"John Herbster" <herb-sci1_AT_sbcglobal.net> wrote
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Thu Jan 19, 2006 7:40 am Post subject: Re: RefreshRecord |
|
|
I have written resync command well and it works on this simple example,
but if I use Join with View containing SUM it does not work.
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: |
Example:
Select C.CityID, C.Name, S.StateID, S.Name As NameOfState
From City As C
Left Join State As S On (S.StateID=C.StateID)
If I change S.StateID I want to refresh S.Name. I do not want to use
requery
'cos it is too slow.
I have tried:
ADO components using properties Recordset.Properties['Resync Command'] and
Recordset.Resync(adAffectCurrent, adResyncAllValues)
TBetterAdo - works with some simple examples, but if I use Join with View
containing SUM it does not work
DbExpress components have implemented RefreshRecord which doesn't work
with
Join
You seem to have to the right code. My guess is that you have not
correctly
written the "Resync command"
for your example it would be
Select C.CityID, C.Name, S.StateID, S.Name As NameOfState
From City As C
Left Join State As S On (S.StateID=C.StateID)
Where C.CityID = ?
Not that if you are using TadoBetterDataset it uses the recordset refresh
equivalent to your code by default when you do a AdoDataset.refresh
and it has a Resync_command property
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Thu Jan 19, 2006 7:42 am Post subject: Re: RefreshRecord |
|
|
Lookup field is very slow.
"Vitali Kalinin" <vitkalinin (AT) yahoo (DOT) com> wrote
| Quote: | This specific case looks like a proper candidate for using Lookup field.
|
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Thu Jan 19, 2006 7:45 am Post subject: Re: RefreshRecord |
|
|
If I use Join with View containing SUM the error message is:
Insufficient key column information for updating or refreshing.
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: |
Example:
Select C.CityID, C.Name, S.StateID, S.Name As NameOfState
From City As C
Left Join State As S On (S.StateID=C.StateID)
If I change S.StateID I want to refresh S.Name. I do not want to use
requery
'cos it is too slow.
I have tried:
ADO components using properties Recordset.Properties['Resync Command'] and
Recordset.Resync(adAffectCurrent, adResyncAllValues)
TBetterAdo - works with some simple examples, but if I use Join with View
containing SUM it does not work
DbExpress components have implemented RefreshRecord which doesn't work
with
Join
You seem to have to the right code. My guess is that you have not
correctly
written the "Resync command"
for your example it would be
Select C.CityID, C.Name, S.StateID, S.Name As NameOfState
From City As C
Left Join State As S On (S.StateID=C.StateID)
Where C.CityID = ?
Not that if you are using TadoBetterDataset it uses the recordset refresh
equivalent to your code by default when you do a AdoDataset.refresh
and it has a Resync_command property
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Mon Jan 23, 2006 2:23 pm Post subject: Re: RefreshRecord |
|
|
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: |
If I use Join with View containing SUM the error message is:
Insufficient key column information for updating or refreshing.
Sounds like your View isn't indexed.
Refreshing requires an index
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
Indexing didn't help.
Many conditions must be satisfied to index View, and when I finally
succeeded I got the same error message.
Full example Delphi 7 and SQL server 2000 :
----------------------------------------------------------------------------------------------------------------------------------------------------
-- SQL
----------------------------------------------------------------------------------------------------------------------------------------------------
Create Database Test
Go
Use Test
Go
CREATE TABLE [TestSKomitent] (
[SKomitent] [int] NOT NULL ,
[Naziv] [nvarchar] (80) COLLATE Croatian_CI_AS NOT NULL , CONSTRAINT
[PK_TestSKomitent] PRIMARY KEY CLUSTERED (
[SKomitent]
) ON [PRIMARY]
) ON [PRIMARY]
GO
Insert Into TestSKomitent(SKomitent, Naziv) Values(1,'test 1') Insert Into
TestSKomitent(SKomitent, Naziv) Values(2,'test 2') GO
CREATE TABLE [TestFaktura] (
[BrojFakture] [int] IDENTITY (1, 1) NOT NULL , [SKomitent] [int] NOT NULL ,
CONSTRAINT [PK_TestFaktura] PRIMARY KEY CLUSTERED (
[BrojFakture]
) ON [PRIMARY] ,
CONSTRAINT [FK_TestFaktura_TestSKomitent] FOREIGN KEY (
[SKomitent]
) REFERENCES [TestSKomitent] (
[SKomitent]
) ON UPDATE CASCADE
) ON [PRIMARY]
GO
Insert Into TestFaktura(SKomitent)
Values(1)
Go
CREATE TABLE [TestFakturaStavke] (
[BrojStavke] [int] NOT NULL ,
[BrojFakture] [int] NOT NULL ,
[SRoba] [int] NOT NULL ,
[Iznos] [numeric](15, 2) NOT NULL ,
CONSTRAINT [PK_TestFakturaStavke] PRIMARY KEY CLUSTERED (
[BrojStavke]
) ON [PRIMARY] ,
CONSTRAINT [FK_TestFakturaStavke_TestFaktura] FOREIGN KEY (
[BrojFakture]
) REFERENCES [TestFaktura] (
[BrojFakture]
) ON UPDATE CASCADE
) ON [PRIMARY]
GO
CREATE View viewTestFaktura As
Select
Fak.BrojFakture,
K.Naziv As SKomitentNaziv,
IsNull(FS.UkupanIznos,0) As UkupanIznos From TestFaktura As Fak Left Join
( Select FS.BrojFakture, Sum(FS.Iznos) As UkupanIznos From TestFakturaStavke
As FS Group By FS.BrojFakture
) As FS On (FS.BrojFakture=Fak.BrojFakture) Left Join TestSKomitent As K On
(K.SKomitent=Fak.SKomitent) Go
----------------------------------------------------------------------------------------------------------------------------------------------------
-- Source
----------------------------------------------------------------------------------------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject); begin
AdoQuery3.Open;
end;
procedure TForm1.ADOQuery3BeforeOpen(DataSet: TDataSet); begin
ADOQuery3.SQL.Clear;
ADOQuery3.SQL.Add('Select');
ADOQuery3.SQL.Add(' Fak.BrojFakture,');
ADOQuery3.SQL.Add(' Fak.SKomitent, V.SKomitentNaziv,');
ADOQuery3.SQL.Add(' V.UkupanIznos');
ADOQuery3.SQL.Add('From TestFaktura As Fak');
ADOQuery3.SQL.Add('Left Join viewTestFaktura As V On
(V.BrojFakture=Fak.BrojFakture)');
end;
procedure TForm1.ADOQuery3AfterOpen(DataSet: TDataSet); begin
ADOQuery3.Properties['Unique Catalog'].Value := 'Test';
ADOQuery3.Properties['Unique Table'].Value := 'TestFaktura';
ADOQuery3.Properties['Resync Command'].Value := ADOQuery3.SQL.Text+#13+
'Where Fak.BrojFakture=?'
End;
procedure TForm1.ADOQuery3BeforePost(DataSet: TDataSet); begin
ADOQuery3.Properties['Update Resync'].Value := adResyncUpdates; end;
procedure TForm1.ADOQuery3AfterPost(DataSet: TDataSet); begin
ADOQuery3.Recordset.Resync(adAffectCurrent, adResyncAllValues); end;
----------------------------------------------------------------------------------------------------------------------------------------------------
-- Error
----------------------------------------------------------------------------------------------------------------------------------------------------
If you try to change field SKomitent from ADOQuery3 from 1 to 2 you'll get
message:
Insufficient key column information for updating or refreshing.
|
|
| Back to top |
|
 |
Vuksa Vladislav Guest
|
Posted: Tue Jan 24, 2006 7:51 am Post subject: Re: RefreshRecord |
|
|
My querys are mutch more complicated from this test example and I have to
use view.
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: | Indexing didn't help.
Many conditions must be satisfied to index View, and when I finally
succeeded I got the same error message.
Then I would advise to not use a view.
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|