need help with an insert statement

Поиск
Список
Период
Сортировка
От Michael Zouroudis
Тема need help with an insert statement
Дата
Msg-id 3D61101E.50709@idealcorp.com
обсуждение исходный текст
Список 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



В списке pgsql-admin по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Fw: OID
Следующее
От: "John Madden"
Дата:
Сообщение: pg_dumpall and output formats?