Re: Forms: reusable pre-insert trigger

From: Mark G <mgumbs_at_nospam.hotmail.com>
Date: Wed, 23 Jun 1999 15:00:35 +0100
Message-ID: <3770e63a.0_at_145.227.194.253>


You could try a more generic procedure
Save the following as a program unit and call it from each pre-insert trigger.
I haven't tested the following so excuse any minor bugs!

Procedure Audit_Details is

v_block              varchar2(30);
v_username     varchar2(30);
v_date                date;

begin

  v_username := get_application_property(username);   select sysdate into v_date from dual;

  • Get the current block v_block := :system.cursor_block;

  copy(v_username, v_block||'.audit_username');   copy(v_date, v_block||'.audit_date');

end;

HTH, Mark

BAMAN MOTIVALA wrote in message ...
>
>
>Hello,
>
>I need to insert and update the userid and the sysdate into audit columns
>every time a user creates or changes a record.
>All of the tables in the database have an audit_username and an audit_date
>column.
>
>Right now I have a form with a block level PRE-INSERT that looks like this:
>
>:block_1.audit_username := get_application_property(username);
>:block_1.audit_date := sysdate;
>
>If I create another block in the form I will have to write another block
>level PRE-INSERT that looks like this:
>
>:block_2.audit_username := get_application_property(username);
>:block_2.audit_date := sysdate;
>
>Note that in both PRE-INSERT triggers the item names are identical. It is
>only the block names that are different.
>
>1) Can I create a form level PRE-INSERT trigger or perhaps a Program Unit
>that will work for both blocks?
>2) Can I somehow substitute the ':block_1' and ':block_2' with some kind of
>variable when assigning the values?
>3) Is there a better way to do this that I am missing?
>
>Thanks,
>
>Baman
>
>
Received on Wed Jun 23 1999 - 16:00:35 CEST

Original text of this message