Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: generic way to get primary key values inside trigger
akhashnobish_at_hotmail.com wrote:
> I need to get the string representation of the value of the primary
> key (possibly multi-column) of the current row being inserted into a
> table from within a post-insert trigger.
>
> The code should not have any hard-coded dependency on the schema of
> the current table.
>
> The following is a schema-dependent implementation of this
>
> -- create a table
> create table test(
> data_type_id number(11),
> name varchar(20),
> primary key(data_type_id, name)
> );
>
> --attach a trigger
> --this is the non-generic version
> create or replace trigger test_trigger
> after insert or update on test
> for each row
> declare
> keystring varchar(100);
> begin
>
> -- I need a generic version of the following line
> select '[' || :new.data_type || '][' || :new.name ']' into
> keystring from dual;
>
> end;
> /
>
>
> Any help is appreciated. Thanks
What you are trying to do, and in what version you are trying to do it is unclear.
But if your intent is to write code that writes triggers without the intervention of testing I would rethink the concept.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Thu Apr 05 2007 - 13:41:11 CDT
![]() |
![]() |