Proble with DefaultExpression

cgi

Member²
First I initialize the property "DefaultExpression" for my fields in the oracledataset methode "InternalInitFieldDefs"

procedure TX1OracleDataSet.InternalInitFieldDefs;
var
i : integer;
begin
Inherited;

InitDefaultExpression;

end;

secondly i call this procedure :

procedure DuplicateAffaire(aIdAffaire : integer);
var
oraqry : TOracleQuery;
begin
oraqry := TOracleQuery.Create(self);
try
oraqry.session := oradstAffaire.Session;
oraqry.DeclareVariable('ID_AFFAIRE', otInteger);
oraqry.SetVariable('ID_AFFAIRE', aIdAffaire);
oraqry.SQL.Add('SELECT * FROM AFFAIRE WHERE ID_AFFAIRE = :ID_AFFAIRE');
oraqry.Execute;

oradstAffaire.Insert;
for i := 0 to oraqry.FieldCount-1 do
begin
if (Query.FieldName(i)'ID_AFFAIRE') then
begin
if oradstAffaire.FindField(oraqry.FieldName(i)) nil then
oradstAffaire.FieldByName(oraqry.FieldName(i)).asVariant := oraqry.Field(i);
end;
end;
oradstAffaire.Post;
finally
oraqry.Free;
end;
end;

The problem :

For example, the field 2 as a default expression like 'A default expression'

if the field 2 of record of oradstAffaire i want to duplicate is null (and only if is null) I obtain the error message :

ORA-00984 : Un nom de colonne n'est pas autoris
 
I'm not sure if I understand the problem, but you probably just need to include the quotes in the DefaultExpression. It is sent to the server as is, so if it is a character value, you need to include the quotes.

------------------
Marco Kalter
Allround Automations
 
Originally posted by mkalter:
I'm not sure if I understand the problem, but you probably just need to include the quotes in the DefaultExpression. It is sent to the server as is, so if it is a character value, you need to include the quotes.


Thanks very very very much, now it's good.

But, is it the better place
(->InternalInitFieldDef) for initialize the TField.DefaultExpression' or
TField.Required, etc ?

Thanks

Sorry for my poor English !!

------------------
Christian Gincheleau
 
If it is dataset specific, I would use the AfterOpen event. If it applies to all your datasets, overriding InternalInitFieldDefs may be a good idea.

------------------
Marco Kalter
Allround Automations
 
Back
Top