I am using postgresql 7.1.2.
I am trying to implement the following pseudo code:
BEGIN
aid = select id from table_a where name = 'test';
if(aid != NULL)
then
{ update set name = 'test_test' where id = aid;
}
else
{ insert into table_a values (nextval('table_a_id_seq'), 'test');
}
COMMIT
But as we know, you can't use control structure in a transaction block.
And I can't use a function either, because in the real application,
there are way too many parameters needed to be passed in order to do the
"insert" or "update".
Is there any tricks I can play here?
Thanks.
--
Wei Weng
Network Software Engineer
KenCast Inc.