Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 3570F9FB8F2 for ; Tue, 27 Feb 2007 13:01:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 14757-02 for ; Tue, 27 Feb 2007 13:00:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp106.plus.mail.mud.yahoo.com (smtp106.plus.mail.mud.yahoo.com [68.142.206.239]) by postgresql.org (Postfix) with SMTP id 987C69FB2EA for ; Tue, 27 Feb 2007 13:00:58 -0400 (AST) Received: (qmail 50796 invoked from network); 27 Feb 2007 17:00:57 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Received:X-YMail-OSG:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=q4ZM4BdN1ibt61nUbwOWFkxoDCoxvNY/OMJnABJZopr80KXd+I51RNzL6/tRnxYlI140dygd3wH6XC9SnCPjN0Cvxyd3mX+M6bR9n935bOgxnaC9INw98VUO7omys8PvMfldTuFOGUPe6yF79yLplp/YeIx57hvQ+y1Nl2bq1sM= ; Received: from unknown (HELO ?10.2.200.151?) (osvaldo_kussama@200.155.30.180 with plain) by smtp106.plus.mail.mud.yahoo.com with SMTP; 27 Feb 2007 17:00:56 -0000 X-YMail-OSG: uLbm4aQVM1mx3x0YJUgXWLzNFkIGt6z.PVRJEiH82dlR3u4j5C7aScLBchHtQJMkZIvayEqvkSDM_p7goc7fELz3y4qwVu8P0k6.KrVxRZyiwI9CvovatdEPG6wpFBE8USmue2Gq18g0zok- Message-ID: <45E464B3.30402@yahoo.com.br> Date: Tue, 27 Feb 2007 14:04:51 -0300 From: Osvaldo Rosario Kussama User-Agent: Thunderbird 1.5.0.9 (X11/20070102) MIME-Version: 1.0 To: hongliu zou , pgsql-sql@postgresql.org Subject: Re: Syntax Error in COPY when =?windows-1252?Q?=93create_?= =?windows-1252?Q?function=94?= References: <35201a90702261904o44c18d99oa9fdbeb0dca4c9c0@mail.gmail.com> In-Reply-To: <35201a90702261904o44c18d99oa9fdbeb0dca4c9c0@mail.gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.978 tagged_above=0 required=5 tests=AWL, BAYES_50, SUBJECT_ENCODED_TWICE, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200702/282 X-Sequence-Number: 27616 hongliu zou escreveu: > Am I forgetting some limitation? > > I get " ERROR: syntax error at or near "$1" > > SQL state: 42601 "with this > > CREATE FUNCTION Import1() RETURNS text AS $$ > DECLARE > path Char(100); > BEGIN > path = 'C:/zhl/hjs/anc_area.att'; > COPY anc_areaAtt FROM path CVS; > Try: EXECUTE 'COPY anc_areaAtt FROM ' || path || ' CVS;'; > > RETURN path; > END; > $$ LANGUAGE plpgsql; > > SELECT Import1() ; > > > But COPY can work well when I just put the string in the command: > > CREATE FUNCTION Import2() RETURNS text AS $$ > DECLARE > path Char(100); > BEGIN > COPY anc_areaAtt FROM 'C:/zhl/hjs/anc_area.att' CSV; > return path; > END; > $$ LANGUAGE plpgsql; > > SELECT Import2() ; > > > |Does this mean the "filename" in COPY command can not be a variable?| > Look Executing Dynamic Commands at: http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN []s Osvaldo _______________________________________________________ Yahoo! Mail - Sempre a melhor opção para você! Experimente já e veja as novidades. http://br.yahoo.com/mailbeta/tudonovo/