how to write a function?

Поиск
Список
Период
Сортировка
От Ireneusz Kramarz
Тема how to write a function?
Дата
Msg-id 001001c3b35b$1deb46a0$0300a8c0@iron
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Tom Ansley
Дата:
Сообщение: Retrieving Array Datatype in Java
Следующее
От: Roy MacGregor Paterson
Дата:
Сообщение: Failed to create a function