X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75E1C329D3B for ; Thu, 9 Sep 2004 18:49:35 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29773-04 for ; Thu, 9 Sep 2004 17:49:28 +0000 (GMT) Received: from web53002.mail.yahoo.com (web53002.mail.yahoo.com [206.190.39.192]) by svr1.postgresql.org (Postfix) with SMTP id 0F8DA329CAE for ; Thu, 9 Sep 2004 18:49:28 +0100 (BST) Message-ID: <20040909174926.81383.qmail@web53002.mail.yahoo.com> Received: from [12.150.114.134] by web53002.mail.yahoo.com via HTTP; Thu, 09 Sep 2004 10:49:26 PDT Date: Thu, 9 Sep 2004 10:49:26 -0700 (PDT) From: the inquirer Subject: PL/pgSQL Function Problem To: pgsql-general@postgresql.org, pgsql-novice@postgresql.org, pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200409/510 X-Sequence-Number: 65716 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