very basic SQL question

Поиск
Список
Период
Сортировка
От Dan Kortschak
Тема very basic SQL question
Дата
Msg-id 1290483559.21375.10.camel@zoidberg.mbs.adelaide.edu.au
обсуждение исходный текст
Ответы Re: very basic SQL question  (Sam Mason <sam@samason.me.uk>)
Re: very basic SQL question  (Matthieu Huin <matthieu.huin@wallix.com>)
Список pgsql-general
Hi,

I'm using Pg for bioinformatic work and I want to be able to insert,
uniquely, biological sequences into a table returning the sequence id -
this part is fine. However, if the sequence already exists in the table
I want to return to id.

At the moment it seems to me that I should do a

SELECT id FROM table WHERE seq = '<sequence>';

and if that gives NULL then

INSERT .... RETURNING id;

But this seems long winded. Is there a better way to achieve what I
want?

thanks


В списке pgsql-general по дате отправления:

Предыдущее
От: David Frankson
Дата:
Сообщение: Extending COALESCE()
Следующее
От: Jayadevan M
Дата:
Сообщение: Re: gap between error and cure