Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8759E632B70 for ; Fri, 19 Mar 2010 11:20:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 72459-09 for ; Fri, 19 Mar 2010 14:20:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd-17937.dedibox.fr (sd-17937.dedibox.fr [88.191.100.74]) by mail.postgresql.org (Postfix) with ESMTP id 7E754641910 for ; Fri, 19 Mar 2010 11:20:38 -0300 (ADT) Received: from [192.168.1.11] (LCaen-151-93-7-26.w80-13.abo.wanadoo.fr [80.13.230.26]) by sd-17937.dedibox.fr (Postfix) with ESMTPA id 0D7743B8F5; Fri, 19 Mar 2010 15:20:36 +0100 (CET) Message-ID: <4BA38833.60804@lelarge.info> Date: Fri, 19 Mar 2010 15:20:35 +0100 From: Guillaume Lelarge User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 To: Julius Tuskenis CC: pgsql-admin@postgresql.org Subject: Re: insert in function writen in pgplsql References: <4BA37FF5.8060001@nsoft.lt> In-Reply-To: <4BA37FF5.8060001@nsoft.lt> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.943 tagged_above=-10 required=5 tests=AWL=0.656, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/140 X-Sequence-Number: 33939 Le 19/03/2010 14:45, Julius Tuskenis a écrit : > Hello > > lets say I have a function add_user(user varchar(20), password > varchar(20)). In its body I want to have statement INSERT INTO > my_users(user, password) VALUES (user, password); The problem is I cant > - then I try to create such function I get "ERROR: syntax error at or > near "$1" > LINE 1: INSERT INTO my_users( $1 .... " This tells me the parameter is > used instead of column name. That is of course not what I wanted. What > would you recommend to fix this? Is there any way to tell the postgres > that user is column name? I tried "user" with same error. Must I change > the names of parameters? > Yes. It would also be easier to debug. -- Guillaume. http://www.postgresqlfr.org http://dalibo.com