[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

unable run \copy command via PGconn.( exec || query

Ashikali Ashikali

4/3/2009 3:10:00 PM



Hi ,
I am facing problem while executing following code :

require 'postgres'
obj = PGconn.new( '192.168.1.156',5432 ,'','','tikono','tikono','tikono'
)
a = "\\COPY
ivr_interface.call_flow(ref_id,loaded_time,menuid,expected_dtmf,expected_dtmf_status,processing_input,confirmation,external_staus,external_value)
from ./backupFiles/ivr_interface.call_flow.new WITH DELIMITER '$' NULL
'nil'"
p a
obj.exec( a )
p obj.methods

Error :
query.rb:5:in `exec': ERROR: syntax error at or near "\" at character 1
(PGError)
from query.rb:5
X=============================X

If I use "\copy ..." , Instead of "\\copy" then I got
query.rb:3: Invalid escape character syntax
a = "\COPY
ivr_interface.call_flow(ref_id,loaded_time,menuid,expected_dtmf,expected_dtmf_status,processing_input,confirmation,external_staus,external_value)
from ./backupFiles/ivr_interface.call_flow.new WITH DELIMITER '$' NULL
'nil'"

Note : Not PGERROR


If I use ,
'\COPY
ivr_interface.call_flow(ref_id,loaded_time,menuid,expected_dtmf,expected_dtmf_status,processing_input,confirmation,external_staus,external_value)
from ./backupFiles/ivr_interface.call_flow.new WITH DELIMITER \'$\'
NULL \'nil\''

I got the Error as ,
query.rb:5:in `exec': ERROR: syntax error at or near "\" at character 1
(PGError)
from query.rb:5

Can anyone tell me How to escape this \copy in PGconn.( query|| exec )
method ?

cheers,
ashikali
--
Posted via http://www.ruby-....

2 Answers

ara.t.howard

4/3/2009 3:20:00 PM

0


On Apr 3, 2009, at 9:09 AM, Ashikali Ashikali wrote:

> Can anyone tell me How to escape this \copy in PGconn.( query|| exec )

all of the \*** commands are implemented by the psql command line
program, not the database, so none of them will ever work with a raw
connection. fyi.

a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Ashikali Ashikali

4/3/2009 4:17:00 PM

0

Ara Howard wrote:
> On Apr 3, 2009, at 9:09 AM, Ashikali Ashikali wrote:
>
>> Can anyone tell me How to escape this \copy in PGconn.( query|| exec )
>
> all of the \*** commands are implemented by the psql command line
> program, not the database, so none of them will ever work with a raw
> connection. fyi.
>
> a @ http://codeforp...

Thanks for your response . But I found the solution using psql command .
That is ,
psql -A -c "\\COPY
ivr_interface.call_reports(pbxid,channeltype,callerid,calledid,landedtime,endedtime,endstatus,endreason,progresslangauge,defaultlanguage,internalerror)
from ./backupFiles/ivr_interface.call_reports.new WITH DELIMITER '$'
NULL 'nil'" -q -t -h 192.168.1.156 -U tikono tikono"

cheers,
ashikali
--
Posted via http://www.ruby-....