Subject | ReadOnly with CDS |
---|---|
Author | fowlertrainer2003 |
Post date | 2003-10-17T09:06:51Z |
Hi !
My problem is that:
I have many times use TClientDataSet with provider support.
I use with IBX, but I want to port it to IBO.
My clientdataset (a customcached version) object is set the provider
to the IBOQuery, and load it's data.
In the IBX, I have no problem with it. But in IBO, the IBOQuery set
his fields to ReadOnly - and the FieldDefs is is containing ReadOnly
Fields to.
Let's see this example:
var
db:TIBODatabase;trs:TIBOTransaction;qry:TIBOQuery;
cds:TK3KSIBOClientDataSet;
ibu:TIBOUpdateSQL;
i:integer;
begin
db:=TIBODatabase.Create(Self);
with db do begin
Params.CommaText:='"user name=sysdba" password=m "CHARACTER
SET=win1250"';
DatabaseName:='c:\dev\bha\database\mpanni.gdb';
LoginPrompt:=False;
SQLDialect:=3;
Open;
end;
trs:=TIBOTransaction.Create(Self);
with trs do begin
IB_Connection:=db;
Isolation:=tiCommitted;
ReadOnly:=True;
// must true, because I don't use writeable
// transactions, only in updates
end;
ibu:=TIBOUpdateSQL.Create(Self);
qry:=TIBOQuery.Create(Self);
// This is the query
with qry do begin
qry.
IB_Connection:=db;
IB_Transaction:=trs;
SQL.Text:='select * from inst_group';
SQL.Text:=
'select c.ID, c.CTT_DATE, c.PERSON_ID, c.CTT_TYPE,'
+
' c.EXTPLACE_ID, c.GROUP_ID, c.INTFROM, c.INTTO, c.INTLEN, c.INT'
+
'TYPE_ID, c.CTT_MEMO, c.MOD_DATE, c.MOD_USER_ID, c.INTLENMIN, c.I'
+
'SINTV_OVERTIME, c.ISINTV_TOPREWORK, c.STUDENT_COUNT, c.PSTYPE_ID'
+
' from ctt_main c, tempsession t where (t.tempsession_id=:TS_I'
+
'D) and (pstype_id=100) and (c.CTT_DATE between :D1 and :D2) and'
+
' (ctt_type=0) and (t.ID=c.PERSON_ID) order by t.ID,c.CTT_DATE,c'
+
'.INTFROM'#13#10;
CachedUpdates:=True;
ReadOnly:=False;
UpdateObject:=ibu;
ParamByName('TS_ID').AsInteger:=440;
ParamByName('D1').AsDateTime:=0;
ParamByName('D2').AsDateTime:=40000;
Open;
//for i:=0 to FieldCount-1 do Fields[i].ReadOnly:=False;
Caption:=IntToStr(ord(CanModify));
Caption:=Caption+IntToStr(ord(Fields[0].ReadOnly));
DataSource1.DataSet:=qry;
// It is show that cannot modify, and fields are
// readonly.
end;
cds:=TK3KSIBOClientDataSet.Create(Self);
with cds do begin
DataBase:=db;
Transaction:=trs;
SQL.Text:=
'select c.ID, c.CTT_DATE, c.PERSON_ID, c.CTT_TYPE,'
+
' c.EXTPLACE_ID, c.GROUP_ID, c.INTFROM, c.INTTO, c.INTLEN, c.INT'
+
'TYPE_ID, c.CTT_MEMO, c.MOD_DATE, c.MOD_USER_ID, c.INTLENMIN, c.I'
+
'SINTV_OVERTIME, c.ISINTV_TOPREWORK, c.STUDENT_COUNT, c.PSTYPE_ID'
+
' from ctt_main c, tempsession t where (t.tempsession_id=:TS_I'
+
'D) and (pstype_id=100) and (c.CTT_DATE between :D1 and :D2) and'
+
' (ctt_type=0) and (t.ID=c.PERSON_ID) order by t.ID,c.CTT_DATE,c'
+
'.INTFROM'#13#10;
Params.ParamByName('TS_ID').AsInteger:=440;
Params.ParamByName('D1').AsDateTime:=0;
Params.ParamByName('D2').AsDateTime:=40000;
Open;
GenerateUpdateSQL('');
Caption:=IntToStr(ord(CanModify));
Caption:=Caption+IntToStr(ord(Fields[0].ReadOnly));
DataSource1.DataSet:=cds;
end;
// It is show just like with IBOQuery
When I use this CDS, I copy it's content like this
newcds.FieldDefs.Assign(cds);
newcds.CreateDataSet;
CopyDataSet(cds,newcds);
or
newcds.FieldDefs.Assign(qry);
newcds.CreateDataSet;
CopyDataSet(qry,newcds);
But it is say that newcds's Fields are ReadOnly, and I cannot modify
them, because the cds.FieldDefs is get from IBOQuery, and it is make
his FieldDefs with Readonly Fields.
The IBX don't do that. Can I change anything in IBO to this thing to
be not happen ?
Thanx for answers !
KK
My problem is that:
I have many times use TClientDataSet with provider support.
I use with IBX, but I want to port it to IBO.
My clientdataset (a customcached version) object is set the provider
to the IBOQuery, and load it's data.
In the IBX, I have no problem with it. But in IBO, the IBOQuery set
his fields to ReadOnly - and the FieldDefs is is containing ReadOnly
Fields to.
Let's see this example:
var
db:TIBODatabase;trs:TIBOTransaction;qry:TIBOQuery;
cds:TK3KSIBOClientDataSet;
ibu:TIBOUpdateSQL;
i:integer;
begin
db:=TIBODatabase.Create(Self);
with db do begin
Params.CommaText:='"user name=sysdba" password=m "CHARACTER
SET=win1250"';
DatabaseName:='c:\dev\bha\database\mpanni.gdb';
LoginPrompt:=False;
SQLDialect:=3;
Open;
end;
trs:=TIBOTransaction.Create(Self);
with trs do begin
IB_Connection:=db;
Isolation:=tiCommitted;
ReadOnly:=True;
// must true, because I don't use writeable
// transactions, only in updates
end;
ibu:=TIBOUpdateSQL.Create(Self);
qry:=TIBOQuery.Create(Self);
// This is the query
with qry do begin
qry.
IB_Connection:=db;
IB_Transaction:=trs;
SQL.Text:='select * from inst_group';
SQL.Text:=
'select c.ID, c.CTT_DATE, c.PERSON_ID, c.CTT_TYPE,'
+
' c.EXTPLACE_ID, c.GROUP_ID, c.INTFROM, c.INTTO, c.INTLEN, c.INT'
+
'TYPE_ID, c.CTT_MEMO, c.MOD_DATE, c.MOD_USER_ID, c.INTLENMIN, c.I'
+
'SINTV_OVERTIME, c.ISINTV_TOPREWORK, c.STUDENT_COUNT, c.PSTYPE_ID'
+
' from ctt_main c, tempsession t where (t.tempsession_id=:TS_I'
+
'D) and (pstype_id=100) and (c.CTT_DATE between :D1 and :D2) and'
+
' (ctt_type=0) and (t.ID=c.PERSON_ID) order by t.ID,c.CTT_DATE,c'
+
'.INTFROM'#13#10;
CachedUpdates:=True;
ReadOnly:=False;
UpdateObject:=ibu;
ParamByName('TS_ID').AsInteger:=440;
ParamByName('D1').AsDateTime:=0;
ParamByName('D2').AsDateTime:=40000;
Open;
//for i:=0 to FieldCount-1 do Fields[i].ReadOnly:=False;
Caption:=IntToStr(ord(CanModify));
Caption:=Caption+IntToStr(ord(Fields[0].ReadOnly));
DataSource1.DataSet:=qry;
// It is show that cannot modify, and fields are
// readonly.
end;
cds:=TK3KSIBOClientDataSet.Create(Self);
with cds do begin
DataBase:=db;
Transaction:=trs;
SQL.Text:=
'select c.ID, c.CTT_DATE, c.PERSON_ID, c.CTT_TYPE,'
+
' c.EXTPLACE_ID, c.GROUP_ID, c.INTFROM, c.INTTO, c.INTLEN, c.INT'
+
'TYPE_ID, c.CTT_MEMO, c.MOD_DATE, c.MOD_USER_ID, c.INTLENMIN, c.I'
+
'SINTV_OVERTIME, c.ISINTV_TOPREWORK, c.STUDENT_COUNT, c.PSTYPE_ID'
+
' from ctt_main c, tempsession t where (t.tempsession_id=:TS_I'
+
'D) and (pstype_id=100) and (c.CTT_DATE between :D1 and :D2) and'
+
' (ctt_type=0) and (t.ID=c.PERSON_ID) order by t.ID,c.CTT_DATE,c'
+
'.INTFROM'#13#10;
Params.ParamByName('TS_ID').AsInteger:=440;
Params.ParamByName('D1').AsDateTime:=0;
Params.ParamByName('D2').AsDateTime:=40000;
Open;
GenerateUpdateSQL('');
Caption:=IntToStr(ord(CanModify));
Caption:=Caption+IntToStr(ord(Fields[0].ReadOnly));
DataSource1.DataSet:=cds;
end;
// It is show just like with IBOQuery
When I use this CDS, I copy it's content like this
newcds.FieldDefs.Assign(cds);
newcds.CreateDataSet;
CopyDataSet(cds,newcds);
or
newcds.FieldDefs.Assign(qry);
newcds.CreateDataSet;
CopyDataSet(qry,newcds);
But it is say that newcds's Fields are ReadOnly, and I cannot modify
them, because the cds.FieldDefs is get from IBOQuery, and it is make
his FieldDefs with Readonly Fields.
The IBX don't do that. Can I change anything in IBO to this thing to
be not happen ?
Thanx for answers !
KK