| From: | the inquirer <listquestions(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org |
| Subject: | PL/pgSQL Function Problem |
| Date: | 2004-09-09 17:49:26 |
| Message-ID: | 20040909174926.81383.qmail@web53002.mail.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-novice pgsql-sql |
I am trying to create a function that creates a user
and adds a row to a table. It produces no warnings or
errors when I create the function but when I attempt
to execute it I get a syntax error. I do not
understand why this is happening. Any help would be
greatly appreciated.
SELECT create_author( 'name', 'username', 'password'
);
ERROR: syntax error at or near "$1" at character 14
CONTEXT: PL/pgSQL function "create_author" line 7 at
SQL statement
Here is the code:
CREATE OR REPLACE FUNCTION create_author (
VARCHAR(32), VARCHAR(32), VARCHAR(32) )
RETURNS INTEGER AS '
DECLARE
name_ ALIAS FOR $1;
username_ ALIAS FOR $2;
password_ ALIAS FOR $3;
authorid_ INTEGER;
BEGIN
CREATE USER username_ WITH ENCRYPTED PASSWORD
password_ IN GROUP authors;
INSERT INTO Authors
( Name, Username )
VALUES
( $1, $2 );
SELECT Max( AuthorID ) INTO authorid_ FROM Authors;
RETURN authorid_;
END;
' LANGUAGE 'plpgsql'
SECURITY INVOKER
RETURNS NULL ON NULL INPUT;
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Edwin Grubbs | 2004-09-09 17:53:57 | referential integrity preventing simultaneous insert |
| Previous Message | Phil Endecott | 2004-09-09 17:42:38 | Re: Obtaining the Julian Day from a date |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pradeepkumar, Pyatalo (IE10) | 2004-09-10 04:31:13 | Re: how to overwrite tuples in a table |
| Previous Message | Tom Lane | 2004-09-09 16:52:26 | Re: Table locks |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Berkus | 2004-09-09 18:37:19 | Re: aggregate function stddev |
| Previous Message | Passynkov, Vadim | 2004-09-09 15:01:38 | Re: Isnumeric function? |