Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 177219FB9A2 for ; Mon, 26 Feb 2007 23:04:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 85570-06 for ; Mon, 26 Feb 2007 23:04:13 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by postgresql.org (Postfix) with ESMTP id 378D09FB7E2 for ; Mon, 26 Feb 2007 23:04:13 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so853734ugf for ; Mon, 26 Feb 2007 19:04:11 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=tKcTLwOFBqQyEOpVs2tWy6eGhcEtyfjGu+oNCzBmLiXIr5pN2/yCcGJLPPqx8K0bfoFAzrmQAesBnzzsVPzdw5BgcEgjvmwmxPrEd9cQEo19fDD51Kie5v6o3py7x/yLBZXAPozLNCd3/PNrwgnwOzrAJPL60sfFF0wxjh4DMJs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=bufPKjbzexvLMVC6OGqkElqzREu2qHtPmwt4t9TzrgDmzNUC/lpnqVhVXYI/9NdW2L5HaZ0Aj5AxdNMka+4y9HvkGYGNkbUB0z6yNb9bKvHXEbKLevPnJ0XQrdmvJpUEsUL5eg7CvmAvLvl+D2d8KRJPqFnhGXBSwlZvuD5Dn0w= Received: by 10.67.101.10 with SMTP id d10mr7427247ugm.1172545451092; Mon, 26 Feb 2007 19:04:11 -0800 (PST) Received: by 10.66.255.1 with HTTP; Mon, 26 Feb 2007 19:04:11 -0800 (PST) Message-ID: <35201a90702261904o44c18d99oa9fdbeb0dca4c9c0@mail.gmail.com> Date: Tue, 27 Feb 2007 11:04:11 +0800 From: "hongliu zou" To: pgsql-sql@postgresql.org Subject: =?WINDOWS-1252?Q?Syntax_Error_in_COPY_when_=93create_function=94?= MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_57088_27779520.1172545451039" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50, HTML_MESSAGE, SPF_PASS, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200702/276 X-Sequence-Number: 27610 ------=_Part_57088_27779520.1172545451039 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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; 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? By the way, my OS is windowXP. Thanks and Regards, Hongliu ------=_Part_57088_27779520.1172545451039 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

 

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;

 

            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?

 

By the way, my OS is windowXP.

 

Thanks and Regards,
Hongliu
------=_Part_57088_27779520.1172545451039--