Print Thread
Proble with DefaultExpression
#3965 10/03/02 02:23 PM
Joined: Oct 1999
Posts: 21
France
C
cgi Offline OP
Member
OP Offline
Member
C
Joined: Oct 1999
Posts: 21
France
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


Christian Gincheleau
Re: Proble with DefaultExpression
#3966 10/03/02 07:54 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
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


Marco Kalter
Allround Automations
Re: Proble with DefaultExpression
#3967 10/04/02 12:45 PM
Joined: Oct 1999
Posts: 21
France
C
cgi Offline OP
Member
OP Offline
Member
C
Joined: Oct 1999
Posts: 21
France
[quote]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.


[/quote]

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


Christian Gincheleau
Re: Proble with DefaultExpression
#3968 10/04/02 06:57 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
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


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.028s Queries: 13 (0.010s) Memory: 2.5183 MB (Peak: 3.0464 MB) Data Comp: Off Server Time: 2024-05-17 04:23:58 UTC
Valid HTML 5 and Valid CSS