| От | javier wilson |
|---|---|
| Тема | Re: Help with seq numbers... |
| Дата | |
| Msg-id | da884c20050214141824fb436e@mail.gmail.com обсуждение исходный текст |
| Ответ на | Help with seq numbers... ("Cristian Prieto" <cristian@clickdiario.com>) |
| Список | pgsql-general |
On Mon, 14 Feb 2005 15:47:06 -0600, Cristian Prieto <cristian@clickdiario.com> wrote: > > why don't you use a serial? that way you don't have to insert it? i > > usually let postgresql take care of it, and you can use currval to > > return a value. > > That's the trouble, I need a sp that returns the user id of the last > inserted user, and 0 if the username or email (another unique index) is > already in the database... what about using a serial for userid, but checking first is the meail or username already exists? so, in your sp, do a: select count(*) from users where email=$1 or username=$2 and then avoid the insert and just return 0? or that would be to much load? javier
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера