From: Kevin Jenkins <gameprogrammer@rakkar.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to test/read a stored procedure that returns a boolean?
Date: Wed, 16 Jan 2008 15:50:41 -0800
Message-ID: <478E9851.9020905@rakkar.org> (raw)
In-Reply-To: <29647.1200526120@sss.pgh.pa.us>
References: <478E901D.7060701@rakkar.org>
<29647.1200526120@sss.pgh.pa.us>
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 $$
declare
num_matches integer;
begin
num_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');
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gameprogrammer@rakkar.org
Subject: Re: How to test/read a stored procedure that returns a boolean?
In-Reply-To: <478E9851.9020905@rakkar.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox