J
jqw
Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi 4.0(Pack #3)+BDE 5.1.1+Oracle 8i;
有一个简单的程序:
database,table,datasource,dbgrid,dbnavigator各一个(见源程序)
在table.beforeEdit中
with database1 do
if not intransaction then
starttransaction;
当修改一条记录后,post,出现"capability not supported.",
难道oracle 8i不支持事务中的修改(好象删除也不支持),可是
在oracle 7.x中是完全支持的。
望各位高手帮忙,如解决的好,还会加分!
附:
(1). unit1.dfm
object Form1: TForm1
Left = 176
Top = 96
Width = 870
Height = 600
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object DBNavigator1: TDBNavigator
Left = 80
Top = 448
Width = 470
Height = 41
DataSource = DataSource1
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 32
Top = 56
Width = 793
Height = 369
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 584
Top = 456
Width = 105
Height = 33
Caption = 'Commit'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 728
Top = 456
Width = 81
Height = 33
Caption = 'Rollback'
TabOrder = 3
OnClick = Button2Click
end
object Database1: TDatabase
AliasName = 'plat_db'
Connected = True
DatabaseName = '1234'
LoginPrompt = False
Params.Strings = (
'USER NAME=platzhk'
'password=platzhk')
SessionName = 'Default'
Left = 64
Top = 8
end
object Table1: TTable
Active = True
BeforeEdit = Table1BeforeEdit
DatabaseName = '1234'
IndexFieldNames = 'A1'
TableName = 'TEST'
Left = 104
Top = 8
end
object DataSource1: TDataSource
DataSet = Table1
Left = 144
Top = 8
end
end
(2).unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, ExtCtrls, DBCtrls, Db, DBTables;
type
TForm1 = class(TForm)
Database1: TDatabase;
Table1: TTable;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
procedure Table1BeforeEdit(DataSet: TDataSet);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure ComStartTransaction;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ComStartTransaction;
begin
with Database1 do
if not inTransaction then
StartTransaction;
end;
procedure TForm1.Table1BeforeEdit(DataSet: TDataSet);
begin
ComStartTransaction;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with Database1 do
if not InTransaction then
Windows.MessageBox(0,PChar('没有事务可提交!'),'提示信息',MB_OK)
else if Windows.MessageBox(0,PChar('真的要保存吗?'),'确认信息',MB_YESNO)=IDYES then
begin
try
Commit;
except
Rollback;
end;
ComStartTransaction;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with Database1 do
if not InTransaction then
Windows.MessageBox(0,PChar('没有事务可放弃!'),'提示信息',MB_OK)
else if Windows.MessageBox(0,PChar('真的要修改吗?'),'确认信息',MB_YESNO)=IDYES then
begin
RollBack;
ComStartTransaction;
end;
end;
end.
有一个简单的程序:
database,table,datasource,dbgrid,dbnavigator各一个(见源程序)
在table.beforeEdit中
with database1 do
if not intransaction then
starttransaction;
当修改一条记录后,post,出现"capability not supported.",
难道oracle 8i不支持事务中的修改(好象删除也不支持),可是
在oracle 7.x中是完全支持的。
望各位高手帮忙,如解决的好,还会加分!
附:
(1). unit1.dfm
object Form1: TForm1
Left = 176
Top = 96
Width = 870
Height = 600
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 120
TextHeight = 16
object DBNavigator1: TDBNavigator
Left = 80
Top = 448
Width = 470
Height = 41
DataSource = DataSource1
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 32
Top = 56
Width = 793
Height = 369
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 584
Top = 456
Width = 105
Height = 33
Caption = 'Commit'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 728
Top = 456
Width = 81
Height = 33
Caption = 'Rollback'
TabOrder = 3
OnClick = Button2Click
end
object Database1: TDatabase
AliasName = 'plat_db'
Connected = True
DatabaseName = '1234'
LoginPrompt = False
Params.Strings = (
'USER NAME=platzhk'
'password=platzhk')
SessionName = 'Default'
Left = 64
Top = 8
end
object Table1: TTable
Active = True
BeforeEdit = Table1BeforeEdit
DatabaseName = '1234'
IndexFieldNames = 'A1'
TableName = 'TEST'
Left = 104
Top = 8
end
object DataSource1: TDataSource
DataSet = Table1
Left = 144
Top = 8
end
end
(2).unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, ExtCtrls, DBCtrls, Db, DBTables;
type
TForm1 = class(TForm)
Database1: TDatabase;
Table1: TTable;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
procedure Table1BeforeEdit(DataSet: TDataSet);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure ComStartTransaction;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ComStartTransaction;
begin
with Database1 do
if not inTransaction then
StartTransaction;
end;
procedure TForm1.Table1BeforeEdit(DataSet: TDataSet);
begin
ComStartTransaction;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with Database1 do
if not InTransaction then
Windows.MessageBox(0,PChar('没有事务可提交!'),'提示信息',MB_OK)
else if Windows.MessageBox(0,PChar('真的要保存吗?'),'确认信息',MB_YESNO)=IDYES then
begin
try
Commit;
except
Rollback;
end;
ComStartTransaction;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with Database1 do
if not InTransaction then
Windows.MessageBox(0,PChar('没有事务可放弃!'),'提示信息',MB_OK)
else if Windows.MessageBox(0,PChar('真的要修改吗?'),'确认信息',MB_YESNO)=IDYES then
begin
RollBack;
ComStartTransaction;
end;
end;
end.