Home > Archive > PostgreSQL Discussion > April 2005 > Change Windows path to Unix path...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Change Windows path to Unix path...
Patrick.FICHE@AQSACOM.COM

2005-04-26, 11:24 am

Hi,

I'm trying to execute COPY command from some pgsql function.
The filename is given as an argument of the function.
But I get the filename like 'F:\tmp\file.txt' and I need to change this to
'F:/tmp/file.txt' before applying the COPY command.

I dind't succeed to replace '\' by '/' in the filename.
Could anybody help me.

Thanks
Patrick

----------------------------------------------------------------------------
---------------
Patrick Fiche
email : patrick.fiche@aqsacom.com
tél : 01 69 29 36 18
----------------------------------------------------------------------------
---------------




Shelby Cain

2005-04-26, 11:24 am


--- Patrick.FICHE@AQSACOM.COM wrote:
> Hi,
>
> I'm trying to execute COPY command from some pgsql
> function.
> The filename is given as an argument of the
> function.
> But I get the filename like 'F:\tmp\file.txt' and I
> need to change this to
> 'F:/tmp/file.txt' before applying the COPY command.
>
> I dind't succeed to replace '' by '/' in the
> filename.


Did you escape the backslash? Postgresql interprets
that as a C-style escape sequence.

Try something like:

create function win32tounix(varchar)
returns varchar
as $$
select replace($1, '\', '/');
$$ language sql;



____________________
____________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Patrick.FICHE@AQSACOM.COM

2005-04-27, 3:23 am

Thanks,

That's exactly what I was looking for.


----------------------------------------------------------------------------
---------------
Patrick Fiche
email : patrick.fiche@aqsacom.com
tel : 01 69 29 36 18
----------------------------------------------------------------------------
---------------




-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Shelby Cain
Sent: mardi 26 avril 2005 17:52
To: Patrick.FICHE@aqsacom.com; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Change Windows path to Unix path...



--- Patrick.FICHE@AQSACOM.COM wrote:
> Hi,
>
> I'm trying to execute COPY command from some pgsql
> function.
> The filename is given as an argument of the
> function.
> But I get the filename like 'F:\tmp\file.txt' and I
> need to change this to
> 'F:/tmp/file.txt' before applying the COPY command.
>
> I dind't succeed to replace '' by '/' in the
> filename.


Did you escape the backslash? Postgresql interprets
that as a C-style escape sequence.

Try something like:

create function win32tounix(varchar)
returns varchar
as $$
select replace($1, '\', '/');
$$ language sql;



____________________
____________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com