From: Osvaldo Rosario Kussama <osvaldo_kussama@yahoo.com.br>
To: hongliu zou <zouhongliu@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Syntax Error in COPY when “create function”
Date: Tue, 27 Feb 2007 14:04:51 -0300
Message-ID: <45E464B3.30402@yahoo.com.br> (raw)
In-Reply-To: <35201a90702261904o44c18d99oa9fdbeb0dca4c9c0@mail.gmail.com>
References: <35201a90702261904o44c18d99oa9fdbeb0dca4c9c0@mail.gmail.com>
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-...
[]s
Osvaldo
_______________________________________________________
Yahoo! Mail - Sempre a melhor opção para você!
Experimente já e veja as novidades.
http://br.yahoo.com/mailbeta/tudonovo/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: osvaldo_kussama@yahoo.com.br, zouhongliu@gmail.com
Subject: Re: Syntax Error in COPY when “create function”
In-Reply-To: <45E464B3.30402@yahoo.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox