Re: How to test/read a stored procedure that returns a boolean?
В списке pgsql-sql по дате отправления:
| От | Kevin Jenkins |
|---|---|
| Тема | Re: How to test/read a stored procedure that returns a boolean? |
| Дата | |
| Msg-id | 478E9851.9020905@rakkar.org обсуждение исходный текст |
| Ответ на | Re: How to test/read a stored procedure that returns a boolean? (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-sql |
Thanks Tom!
Also, how do I check if a language is already created so I don't load
it twice?
"ERROR: language "plpgsql" already exists
SQL state: 42710"
Here is the code fixed.
/*
CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL';
CREATE TABLE handles (
handleID_pk serial PRIMARY KEY UNIQUE NOT NULL,
userID_fk integer UNIQUE NOT NULL,
handle text UNIQUE NOT NULL);
CREATE TABLE disallowedHandles (
handle text UNIQUE NOT NULL);
*/
create or replace function IsUsedHandle(h text) returns boolean as $$
declarenum_matches integer;
beginnum_matches := COUNT(*) from handles where handles.handle = h;return num_matches > 0;
end;
$$ LANGUAGE plpgsql;
-- INSERT INTO handles (handle, userid_fk) VALUES ('blah', 0);
select * from IsUsedHandle('blah');
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера