Re: [SQL] automatic update or insert

2005-10-26 Thread Patrick JACQUOT
tobbe wrote: Hi. I have a little problem. In a system of mine i need to insert records into table [tbStat], and if the records exist i need to update them instead and increase a column [cQuantity] for every update. I.e. the first insert sets cQuantity to 1, and for every other run cQuantity i

Re: [SQL] automatic update or insert

2005-10-25 Thread codeWarrior
The following trigger procedure works for me you'd need to adjust this to manipulate YOUR table schema: DROP FUNCTION dmc_comp_plan_duplicates() CASCADE; CREATE OR REPLACE FUNCTION dmc_comp_plan_duplicates() RETURNS "trigger" AS $BODY$ DECLARE did integer; BEGIN SELECT COALESCE(id,

Re: [SQL] automatic update or insert

2005-10-25 Thread Daryl Richter
tobbe wrote: Hi. I have a little problem. In a system of mine i need to insert records into table [tbStat], and if the records exist i need to update them instead and increase a column [cQuantity] for every update. I.e. the first insert sets cQuantity to 1, and for every other run cQuantity is

Re: [SQL] automatic update or insert

2005-10-25 Thread PFC
In a system of mine i need to insert records into table [tbStat], and if the records exist i need to update them instead and increase a column [cQuantity] for every update. I.e. the first insert sets cQuantity to 1, and for every other run cQuantity is increased. Currently i have implemented t

Re: [SQL] automatic update or insert

2005-10-24 Thread Stewart Ben (RBAU/EQS4) *
> Currently i have implemented this as a stored procedure in the plpgsql > language. This means that in my stored procedure i first do a > select to > find out if the row exists or not, then i do a insert or update > depending if the row existed. > > Unfortunately, stored procedures seems awfull

[SQL] automatic update or insert

2005-10-24 Thread tobbe
Hi. I have a little problem. In a system of mine i need to insert records into table [tbStat], and if the records exist i need to update them instead and increase a column [cQuantity] for every update. I.e. the first insert sets cQuantity to 1, and for every other run cQuantity is increased. Cu