Subject | RE: [ib-support] About default values |
---|---|
Author | Kaputnik |
Post date | 2001-12-17T19:57:07Z |
Exactly this is what triggers are for:
excerpt from my own databases, where every table has these before insert and
before update triggers:
due to automatically adding the same fields for all tables I can create
these triggers as DDL through a small utility I wrote automatically.....
before insert:
BEGIN
IF (new.id IS NULL) THEN new.id=GEN_ID(GEN_something,1); //this is a
tribute to IBO and its generatorlinks....
new.SYS$CHANGED_AT='NOW';
new.SYS$CREATED_AT='NOW';
new.SYS$CHANGED_BY=CURRENT_USER;
new.SYS$CREATED_BY=CURRENT_USER;
END
before update:
BEGIN
new.SYS$CHANGED_AT='NOW';
new.SYS$CHANGED_BY=CURRENT_USER;
new.SYS$CREATED_AT=old.SYS$CREATED_AT;
new.SYS$CREATED_BY=old.SYS$CREATED_BY;
END
This is perfect and ensures that the values are always filled the proper
way, i.e. even if the user changes something manually, it would be right
after posting.
CU,
Nick Josipovic
CRM Administration
BIT-Institute
Prof. Dr. Franz Steffens
Schloss
68163 Mannheim
Germany
Phone: ++49 621 181-1621
Fax: ++49 621 181-1618
mailto:nick.josipovic@...
excerpt from my own databases, where every table has these before insert and
before update triggers:
due to automatically adding the same fields for all tables I can create
these triggers as DDL through a small utility I wrote automatically.....
before insert:
BEGIN
IF (new.id IS NULL) THEN new.id=GEN_ID(GEN_something,1); //this is a
tribute to IBO and its generatorlinks....
new.SYS$CHANGED_AT='NOW';
new.SYS$CREATED_AT='NOW';
new.SYS$CHANGED_BY=CURRENT_USER;
new.SYS$CREATED_BY=CURRENT_USER;
END
before update:
BEGIN
new.SYS$CHANGED_AT='NOW';
new.SYS$CHANGED_BY=CURRENT_USER;
new.SYS$CREATED_AT=old.SYS$CREATED_AT;
new.SYS$CREATED_BY=old.SYS$CREATED_BY;
END
This is perfect and ensures that the values are always filled the proper
way, i.e. even if the user changes something manually, it would be right
after posting.
CU,
Nick Josipovic
CRM Administration
BIT-Institute
Prof. Dr. Franz Steffens
Schloss
68163 Mannheim
Germany
Phone: ++49 621 181-1621
Fax: ++49 621 181-1618
mailto:nick.josipovic@...
> -----Original Message-----
> From: Clément Doss [mailto:cdoss@...]
> Sent: Monday, December 17, 2001 9:19 PM
> To: ib-support@yahoogroups.com
> Subject: [ib-support] About default values
>
>
> Hi,
>
> I would like to use 2 date fields in my tables:
> Insert_Date
> LastUpdate_Date
>
> Both would have a 'NOW' default value when inserting.
> LastUpdate_Date would be updated when the record is updated too.
>
> I don´t want the user the insert a value in those fields, but I
> have to show them these values.
> So, in the select I will have to include them, but at insert and
> edit/update not right?
> Can I use IBO properties INSERTSQL and EDITSQL for this? By using
> them, I wouldn´t include the
> fields in the expression and the problem would be solved.
> Is there a better way to do this?
>
> Best regards,
> Clément
>
> By the way... Should I ask Santa for two special field types such
> as AtInsertDate and AtUpdateDate
> that would do this all by themselves? :-)
>
>
>