From: | Osvaldo Rosario Kussama <osvaldo_kussama(at)yahoo(dot)com(dot)br> |
---|---|
To: | hongliu zou <zouhongliu(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Syntax Error in COPY when “create function” |
Date: | 2007-02-27 17:04:51 |
Message-ID: | 45E464B3.30402@yahoo.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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/
From | Date | Subject | |
---|---|---|---|
Next Message | Rommel the iCeMAn | 2007-02-27 17:16:42 | Re: Change the Default Database |
Previous Message | Steve Midgley | 2007-02-27 16:38:56 | Re: Change the Default Database |