Subject | Re: [IBO] Beginnig is hard - Triggers and Not NULL |
---|---|
Author | Helen Borrie (TeamIBO) |
Post date | 2002-01-12T13:45:58Z |
At 12:41 PM 12-01-02 +0000, you wrote:
FieldByName(SYS_CHG_USER').AsString := cnMain.Username;
But it won't be necessary because the domain T_USER defaults to USER, so all you need to do is switch off the REQUIRED attribute for that column.
As far as defaulting SYS_CHG_DATE, if you want the client datestamp, just use Now (with no quotes), since Delphi has a Now function that will cause a TDateTime to be passed in. But if you want server time, you'll need to a trigger and switch off the REQUIRED attribute on the client side.
However, if you inspect the SQL property of the script in Tutorial 1, you'll see that Jason defined triggers for that column...check out what the triggers and domains do before doing anything too radical on the client side.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at www.ibobjects.com
>Helen,They are different. The default for the T_USER domain is a server system variable, whereas that for T_DATE is a date literal.
>
>Thank you very much for the detailed explanation.
>
>What is still a misterious for me is why it is not possible to insert
>records in the BasicTutorial6. You allways get a "SYS_CHG_USER" is a
>required value. If set this value in the DefaultValues property it
>works. I did not see any difference between the definition
>of "SYS_CHG_USER" and "SYS_CHG_DATE". Why does the one work and the
>other not ?
>BTW the default of "SYS_CHG_USER" is 'USER'. How to set this viaHmm, I don't think you could. If you just entered USER as your Default, the word 'USER' would be stored, not the unquoted USER keyword. You can do it yourself, in the dataset's BeforePost event, i.e.
>DefaultValues ?
FieldByName(SYS_CHG_USER').AsString := cnMain.Username;
But it won't be necessary because the domain T_USER defaults to USER, so all you need to do is switch off the REQUIRED attribute for that column.
As far as defaulting SYS_CHG_DATE, if you want the client datestamp, just use Now (with no quotes), since Delphi has a Now function that will cause a TDateTime to be passed in. But if you want server time, you'll need to a trigger and switch off the REQUIRED attribute on the client side.
However, if you inspect the SQL property of the script in Tutorial 1, you'll see that Jason defined triggers for that column...check out what the triggers and domains do before doing anything too radical on the client side.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at www.ibobjects.com