Refresh record not working

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Refresh record not working

Post by Valgardur » Mon 25 Aug 2014 14:37

When calling refresh record (to get fields form joined table) nothing refresh actually happens.

The user is inserting a record in one form and I would like to update the grid view on another form without refreshing the whole dataset (which does work). To be sure I kept the key value and located the record, as well as refreshing the grid in other form.

PS I did try "SmartFetch" but it resulted in an invalid SQL error message.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refresh record not working

Post by AlexP » Tue 26 Aug 2014 08:09

Hello,

The RefreshRecord method updates the current record in the DataSet. in order for new records inserted externally to be added to the DataSet automatically, you should use the OraChangeNotification component. You can find a sample of working with this component in the ODAC demos.

P.S. Please provide the error message text or a screenshot at using SmartFetch, as well as the query causing the error.

Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Re: Refresh record not working

Post by Valgardur » Tue 26 Aug 2014 10:37

The record is already visible in the dataset, the user inserts a record, the key fields of the new record are displayed correctly in the form with the grid. After post/commit I locate the new record in the grid and call RefreshRecord, hoping to update values from other tables, tables joined in a query.

PS. I will have to send this later I don't have access at the moment..

Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Re: Refresh record not working

Post by Valgardur » Tue 26 Aug 2014 10:58

The SmartRefresh produces ORA-00933: SQL command not properly ended.

Without SmartRefresh it works fine, normal Refresh as well, RefreshRecord does not give an error, but does not work. I can send you the query in an e-mail, but I cannot post here.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refresh record not working

Post by AlexP » Tue 26 Aug 2014 11:17

If you are using JOIN, you should specify the correct query by yourself to for record update in the SQLRefresh property of this DataSet. By default, a query is generated for one table (the first one in the query).

Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Re: Refresh record not working

Post by Valgardur » Tue 26 Aug 2014 11:21

That would not work.

Refresh works fine, but it is a large dataset and I am looking for a way be able to refresh just this record of the query result.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refresh record not working

Post by AlexP » Tue 26 Aug 2014 13:43

The SQLRefresh property is designed for updating one record. For this, SQL must have an update condition with a parameter, to which the unique key will be put for this query. For example, if your main query is like the following:

Code: Select all

SELECT D.DEPTNO, D.DNAME, E.EMPNO, E.ENAME FROM DEPT D, EMP E WHERE D.DEPTNO = E.EMPNO
then the following record update query will be generated automatically:

Code: Select all

SELECT DEPTNO, DNAME FROM DEPT WHERE DEPTNO = :DEPTNO
In the SQLRefresh property, you should set an update query, that will take into account the second table too, i.e.:

Code: Select all

SELECT D.DEPTNO, D.DNAME, E.EMPNO, E.ENAME FROM DEPT WHERE D.DEPTNO = E.DEPTNO AND D.DEPTNO = :DEPTNO AND E.EMPNO = :EMPN
O

In this case,when calling RefreshRecord, only one column with the current values of the DEPTNO and EMPNO key fields will be updated.

Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Re: Refresh record not working

Post by Valgardur » Tue 26 Aug 2014 13:52

Thanks, OK my misunderstanding.. I thought that SQL Refresh was used to refresh the dataset as well, and as it worked fine I assumed it would for RefreshRecord..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refresh record not working

Post by AlexP » Tue 26 Aug 2014 15:03

Please provide the text of the query leading to the error in the SmartFetch mode. In addition, please specify the options of the DataSet, whose values differ from the default ones.

Valgardur
Posts: 165
Joined: Tue 24 Nov 2009 19:33

Re: Refresh record not working

Post by Valgardur » Tue 26 Aug 2014 15:04

Can I send the query by an e-mail?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refresh record not working

Post by AlexP » Wed 27 Aug 2014 07:38

You can send the query to alexp*devart*com .

Post Reply