how to write a function?

From: "Ireneusz Kramarz" <ikramarz(at)wsb-nlu(dot)edu(dot)pl>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: how to write a function?
Date: 2003-11-25 13:50:32
Message-ID: 001001c3b35b$1deb46a0$0300a8c0@iron
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi, I got a problem with writing a proper function.
I got a table 'stock' with fields like 'stock' and 'sold'.
Now, I need a function that would decrease the number in 'stock', when I insert a certain value into 'sold', by that certain value.

eg. stock=40 sold=0
I insert ' 2' into sold, and it should be like that
stock=38 sold=2

How to do this? I'm really green in the triggers stuff, so please send me some examples for solving this problem.

I apreciate your help so much, iron

Browse pgsql-novice by date

  From Date Subject
Next Message Roy MacGregor Paterson 2003-11-25 15:55:43 Failed to create a function
Previous Message Tom Ansley 2003-11-24 23:50:27 Retrieving Array Datatype in Java