Re: Auomatic numbering, replacing nulls and IF
От | Gregory Wood |
---|---|
Тема | Re: Auomatic numbering, replacing nulls and IF |
Дата | |
Msg-id | 00bd01c1d024$987eee60$7889ffcc@comstock.com обсуждение исходный текст |
Ответ на | Auomatic numbering, replacing nulls and IF ("Pestilence" <me@work.com>) |
Список | pgsql-general |
> 1) Is it possible to create an INT PRIMARY KEY column that automagically > numbers itself? MS-SQL does this using the IDENTITY keyword. As you already mentioned, SERIAL/SEQUENCEs. > 2) The ISNULL function in both Oracle and MS-SQL takes 2 numbers and returns > the second if the first is null, otherwise it returns the first. ISNULL in > Postgres seems to be something quite different. Before I go writing my own > function to do it, is there one already? I think you're looking for coalesce(): "COALESCE(value[, ...]) The COALESCE function returns the first of its arguments that is not NULL. This is often useful to substitute a default value for NULL values when data is retrieved for display, for example: SELECT COALESCE(description, short_description, '(none)') ...' > 3) How do I do 'IF this_sql THEN that_sql'? I keep getting: > parse error at or near "IF" I'm not sure exactly what you need... but it sounds a lot like CASE: http://postgresql.overtone.org/users-lounge/docs/7.2/postgres/functions-cond itional.html Greg
В списке pgsql-general по дате отправления: