how to write a function? - Mailing list pgsql-novice

From Ireneusz Kramarz
Subject how to write a function?
Date
Msg-id 001001c3b35b$1deb46a0$0300a8c0@iron
Whole thread Raw
List 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

pgsql-novice by date:

Previous
From: Tom Ansley
Date:
Subject: Retrieving Array Datatype in Java
Next
From: Roy MacGregor Paterson
Date:
Subject: Failed to create a function