Dataset.post method clears the dataset

Hello.

I'm using Delphi 6 with BDE against Oracle in a native connection.
I'm doing the following scenario:
1. Insert a new record to a table, use POST to save it.
2. Go to edit mode and change some values in some fields.
3. Use the POST method to save the data.
4. The dataset is now empty. The record was gone (even though it is saved in
the database).

The problem happened in my application, but I've created a test application that simply adds new records to the database, and this behaviour remains.

Why running the POST method after edit causes the data to disappear from the
dataset?

Any ideas of how to solve this problem (running a query to select the record
I've just updated is not the answer I'm looking for :) )?

Thanks.

LVL 5
yronnenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jcondeCommented:
Can you post the code for the demo app ? ... the one that inserts the records and calls post.

At a glance, this sounds like a bug in the oracle driver.  Since I don't have access to Oracle, it will be much easier to deduce what's going on if you post some of your code!
0
MamouriCommented:
Hi!
perhaps your inserting in a detail record and master-detail fields are not set correctly!

BTW as jconde said you have to send your source code and table struction. then we can provide more information!

Regards
0
geobulCommented:
Hi,

Does your dataset have a filter? Perhaps after modifying some fields (Edit then Post) your current record goes out of the filter scope.

Regards, Geo
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

yronnenAuthor Commented:
Nope.

No filters.

I can even pinpoint the proble, it happens ONLY if you insert a record, post it, get to edit mode, do changes and post it again.
0
MamouriCommented:
Hi!

Please create a test project and copy the source code of main unit, the dfm code of main form and structure of database you are using!

Then people in EE can help more!

Regards
0
yronnenAuthor Commented:
here's a sample code that causes the same problems:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, DB, DBTables;

type
  TForm1 = class(TForm)
    Database1: TDatabase;
    Query1: TQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    CheckBox1: TCheckBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    CheckBox2: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  Query1.Active := not Query1.Active;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if not (Query1.State in [dsInsert, dsEdit]) then
    Query1.Insert;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if Query1.State in [dsInsert, dsEdit] then
    Query1.Post;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Query1.Edit;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Query1.Delete;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  Query1.ApplyUpdates;
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
  Query1.CachedUpdates := CheckBox2.Checked;
end;

end.



and the DFM:

object Form1: TForm1
  Left = 192
  Top = 110
  Width = 408
  Height = 322
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object DBGrid1: TDBGrid
    Left = 24
    Top = 24
    Width = 320
    Height = 120
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object DBNavigator1: TDBNavigator
    Left = 24
    Top = 152
    Width = 320
    Height = 25
    DataSource = DataSource1
    Flat = True
    TabOrder = 1
  end
  object CheckBox1: TCheckBox
    Left = 56
    Top = 248
    Width = 97
    Height = 17
    Caption = 'Open'
    TabOrder = 2
    OnClick = CheckBox1Click
  end
  object Button1: TButton
    Left = 240
    Top = 192
    Width = 75
    Height = 25
    Caption = 'Insert'
    TabOrder = 3
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 240
    Top = 224
    Width = 75
    Height = 25
    Caption = 'Post'
    TabOrder = 4
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 320
    Top = 192
    Width = 75
    Height = 25
    Caption = 'Edit'
    TabOrder = 5
    OnClick = Button3Click
  end
  object Button4: TButton
    Left = 320
    Top = 224
    Width = 75
    Height = 25
    Caption = 'Delete'
    TabOrder = 6
    OnClick = Button4Click
  end
  object Button5: TButton
    Left = 240
    Top = 256
    Width = 75
    Height = 25
    Caption = 'ApplyUpdates'
    TabOrder = 7
    OnClick = Button5Click
  end
  object CheckBox2: TCheckBox
    Left = 56
    Top = 272
    Width = 97
    Height = 17
    Caption = 'CachedUpdates'
    TabOrder = 8
    OnClick = CheckBox2Click
  end
  object Database1: TDatabase
    AliasName = 'ADA_LIFE_DEV'
    DatabaseName = 'Sabi'
    LoginPrompt = False
    Params.Strings = (
      'SERVER NAME=ADADEV'
      'USER NAME=ADA_LIFE'
      'PASSWORD=artis')
    SessionName = 'Default'
    Left = 32
    Top = 200
  end
  object Query1: TQuery
    DatabaseName = 'Sabi'
    RequestLive = True
    SQL.Strings = (
      'SELECT * FROM A43')
    Left = 96
    Top = 200
  end
  object DataSource1: TDataSource
    DataSet = Query1
    Left = 136
    Top = 200
  end
end
0
ee_ai_constructCommented:
Closed, 500 points refunded.
ee_ai_construct
Community Support Moderator
(re-order part number xm34)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.