please some help on trigger creation

Started by Feite Brekeveldabout 25 years ago2 messagesgeneral
Jump to latest
#1Feite Brekeveld
feite.brekeveld@osiris-it.nl

Hi,

Suppose:

create table rawrecords (
myrec text;
);

create table cookedrecords (
id varchar(10) not null,
name varchar(20) not null,
value integer not null
);

We insert a record say string: "thisid/thisname/12345" into the
rawrecords table.

I would like to have a trigger on that table that splits the raw record
into:

thisid thisname 12345

and inserts those in the cookedrecords table.

It's easy to split such a string using a perl function but how to get
them in the table then ?

Seperate functions to get each attribute ? seems quite expensive !

Am I overlooking some posibilities here ?

Thanks,

Feite Brekeveld

#2will trillich
will@serensoft.com
In reply to: Feite Brekeveld (#1)
Re: please some help on trigger creation

On Mon, Mar 12, 2001 at 11:45:13PM +0100, Feite Brekeveld wrote:

Suppose:

create table rawrecords (
myrec text;
);

create table cookedrecords (
id varchar(10) not null,
name varchar(20) not null,
value integer not null
);

We insert a record say string: "thisid/thisname/12345" into the
rawrecords table.

I would like to have a trigger on that table that splits the raw record
into:

thisid thisname 12345

and inserts those in the cookedrecords table.

It's easy to split such a string using a perl function but how to get
them in the table then ?

<guess factor=blind>
maybe plug items into the NEW pseudorecord...?
similar to a CREATE RULE type of thing?

create rule
add_rec
as on insert to my_view
do instead
insert into my_table (
fullname,
yadayada
) values (
NEW.lastname || ', ' || NEW.firstname,
NEW.something / NEW.somethingelse + NEW.theotherthing
);

</guess>

--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
-- Isaac Asimov, 'The Genetic Code'

will@serensoft.com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!