Stored Procedure: Copy table from; path = text variable

Started by Charles Parealmost 19 years ago7 messagesgeneral
Jump to latest
#1Charles Pare
debile_trash@hotmail.com

Hi, in a stored procedure, if I do COPY table FROM 'mypath' DELIMITERS '\t'; it works but if my path is a text variable which contain my path, i.e.COPY table FROM mytextvar DELIMITERS '\t'; it doesn't work, I get ERROR: syntax error at or near "$1"SQL state: 42601Context: SQL statement in PL/PgSQL function "parseinsert" near line 15Is there any workaround? I want to create a temporary table, copy from and parse the table, all with dynamic path depending of how the function is called.Thank'sCharles
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

#2Richard Huxton
dev@archonet.com
In reply to: Charles Pare (#1)
Re: Stored Procedure: Copy table from; path = text variable

Charles Pare wrote:

Hi, in a stored procedure, if I do COPY table FROM 'mypath'
DELIMITERS '\t'; it works but if my path is a text variable which
contain my path, i.e.COPY table FROM mytextvar DELIMITERS '\t'; it
doesn't work, I get ERROR: syntax error at or near "$1"SQL state:
42601Context: SQL statement in PL/PgSQL function "parseinsert" near
line 15Is there any workaround? I want to create a temporary table,
copy from and parse the table, all with dynamic path depending of how
the function is called.Thank'sCharles

Try building your COPY as text and use EXECUTE.

--
Richard Huxton
Archonet Ltd

#3Charles Pare
debile_trash@hotmail.com
In reply to: Richard Huxton (#2)
Re: Stored Procedure: Copy table from; path = text variable

Wow, it works greatThank's for the quick answerThe Postgres community is amazing!Charles> Date: Tue, 3 Jul 2007 20:01:03 +0100> From: dev@archonet.com> To: debile_trash@hotmail.com> CC: pgsql-general@postgresql.org> Subject: Re: [GENERAL] Stored Procedure: Copy table from; path = text variable> > Charles Pare wrote:> > Hi, in a stored procedure, if I do COPY table FROM 'mypath'> > DELIMITERS '\t'; it works but if my path is a text variable which> > contain my path, i.e.COPY table FROM mytextvar DELIMITERS '\t'; it> > doesn't work, I get ERROR: syntax error at or near "$1"SQL state:> > 42601Context: SQL statement in PL/PgSQL function "parseinsert" near> > line 15Is there any workaround? I want to create a temporary table,> > copy from and parse the table, all with dynamic path depending of how> > the function is called.Thank'sCharles > > Try building your COPY as text and use EXECUTE.> > -- > Richard Huxton> Archonet Ltd> > ---------------------------(end of broadcast)---------------------------> TIP 4: Have you searched our list archives?> > http://archives.postgresql.org/
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

#4Richard Huxton
dev@archonet.com
In reply to: Charles Pare (#3)
Re: Stored Procedure: Copy table from; path = text variable

Charles Pare wrote:

Wow, it works great
Thank's for the quick answer

12 minutes? I've seen bug-patches turned around quicker than that by Tom
;-)

The Postgres community is amazing!

Mostly by volunteers helping out on lists :-)
There's always someone out there you can lend a helping hand to.

--
Richard Huxton
Archonet Ltd

#5Dave Page
dpage@pgadmin.org
In reply to: Richard Huxton (#4)
Re: Stored Procedure: Copy table from; path = text variable

Richard Huxton wrote:

Charles Pare wrote:

Wow, it works great
Thank's for the quick answer

12 minutes? I've seen bug-patches turned around quicker than that by Tom
;-)

Yeah, that's really quite disappointing Richard - you need to pull your
socks up :-)

/D

#6Richard Huxton
dev@archonet.com
In reply to: Dave Page (#5)
Re: Stored Procedure: Copy table from; path = text variable

Dave Page wrote:

Richard Huxton wrote:

Charles Pare wrote:

Wow, it works great
Thank's for the quick answer

12 minutes? I've seen bug-patches turned around quicker than that by Tom
;-)

Yeah, that's really quite disappointing Richard - you need to pull your
socks up :-)

Would have been under the 10, but it took me 2 minutes to make love to
my wife. I'm getting faster all the time though :-)

--
Richard Huxton
Archonet Ltd

#7Dave Page
dpage@pgadmin.org
In reply to: Richard Huxton (#6)
Re: Stored Procedure: Copy table from; path = text variable

Richard Huxton wrote:

Dave Page wrote:

Richard Huxton wrote:

Charles Pare wrote:

Wow, it works great
Thank's for the quick answer

12 minutes? I've seen bug-patches turned around quicker than that by Tom
;-)

Yeah, that's really quite disappointing Richard - you need to pull your
socks up :-)

Would have been under the 10, but it took me 2 minutes to make love to
my wife. I'm getting faster all the time though :-)

OK, now thats a response I wasn't expecting - and a mental image I could
have done without!

/D