By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

maximum function

P: 1
In a function we r finding max value of a column which is hving an id value and then incrementing the column value by adding 1 to the value . now we have to check if max value is zero (ie that column has no value) then we have to write 1 in the column and start incrementing them. how to do this. plz reply as soon as possible.
Jul 17 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 534
If your function is written in plpgsql you should learn here about control structures

If you preferred to use SQL then read about conditional expressions

You may also be interested in using a sequence
This way you'll never have to worry about checking for NULL or incrementing value.
What is also important sequence will provide safety, otherwise you may need to lock the table to prevent two processes intervening with each other in the process of checking/incrementing the value.
Jul 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.