need help with an insert statement

From: Michael Zouroudis <mzouroudis(at)idealcorp(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: need help with an insert statement
Date: 2002-08-19 15:34:54
Message-ID: 3D61101E.50709@idealcorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

sorry if this becomes a little long, but i want to fully explain the
problem.

three tables;
create table asset(
asset_id serial primary key
);

create table software(
software_id serial primary key
);

create table software_asset(
asset_id integer not null
software_id integer not null
);

what i'm aiming for is to get a function that inserts into the
software_asset table from the software table. i already have a working
function on assets that inserts into software. when that happens, i
need it to set off the function on software to insert into
software_asset. here is the function i am having problems with;

create function soft_asset() returns opaque as '

declare
s software%ROWTYPE;
a assets%ROWTYPE;
sa software_asset%ROWTYPE;
s_id integer;
a_id integer;
asset_id integer;
x integer;

begin

select currval (''assets_asset_id_seq'') into x;
select currval (''software_software_id_seq'') into s_id;

raise notice ''last value = %'', x;
raise notice ''last value = %'', s_id;

insert into software_asset (software_id, asset_id) values (s_id, x);

return null;

end;

create trigger now after insert or update on software
for each row execute procedure soft_asset();

the error happens on the insert statement. if i comment that line out,
it returns a value on the notice, but i can't figure out how to return
that value. if anybody can, i would appreicate their help.

thanks in advance,

mike

--
Mike Zouroudis
Intern
__________________________________________________
I.D.E.A.L. Technology Corporation - Orlando Office
http://www.idealcorp.com - 407.999.9870 x14

Browse pgsql-admin by date

  From Date Subject
Next Message John Madden 2002-08-19 16:16:31 pg_dumpall and output formats?
Previous Message Tom Lane 2002-08-19 15:04:01 Re: Fw: OID