473,418 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Exporting in CSV format using where condition

1
Dear All,

I have been facing below issue when trying to export table data in CSV format only when used where condition.
I dont see any issue if I dont use where condition.
Eg:
Succesfully copied to CSV
Expand|Select|Wrap|Line Numbers
  1. dnsdb=> \copy domains to  '/root/pgdata/mycsv.csv' csv;
COPY
Failing with below error when added where condition

Expand|Select|Wrap|Line Numbers
  1. dnsdb=> \COPY (SELECT * FROM DOMAINS where id='20313') to mycsv_2.csv;
  2. ERROR:  syntax error at or near "("
  3. LINE 1: COPY  ( SELECT * FROM DOMAINS where id= '20313' ) TO STDOUT ...

I have been doing this with connecting from remote to postgresql database in DC.
psql client version
Expand|Select|Wrap|Line Numbers
  1. [root@ip-10-101-48-155~]# psql --version
  2. psql (PostgreSQL) 10.17
  3. [root@ip-10-101-48-155 ~]#
PostgreSQL server version

Expand|Select|Wrap|Line Numbers
  1. dnsdb=> select version();
  2.                                                  version
  3. ---------------------------------------------------------------------------------------------------------
  4.  PostgreSQL 8.1.23 on i386-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
  5. (1 row)
Jun 28 '22 #1
0 8723

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Xamalaek | last post by:
Hello, Is it possible to transform an XML document to a binary format using XSL? If so what standards exist that define such transformantions? Regards, X
1
by: GSR | last post by:
Can you suggest me, How to export data from database and user input to cusomized xml format using webservice. xml format may change some times, so should be scalable to export to that format. Please...
0
by: charlie weaver | last post by:
Is it possible to send an email in HTML format using and Access Form created with VB 6? Currently my form sends as RTF, but I cant seem to figure out how to send in HTML format.
1
by: svnlakshmi | last post by:
Pls help me out in this aspect--How to convert a binary file to a file in text format using C?
1
by: sharan | last post by:
Using the expat parser (http://expat.sourceforge.net/) i have to parse the following xml file and print it on the screen in tabular format using C language. i am getting ouput serially but not in...
5
theGeek
by: theGeek | last post by:
Hi All, I want to save the current page using javascript(in asp.net). Though I could find out that the "execCommand" can do that but the only options for file types that are available in the save...
1
by: URpooja | last post by:
Dear frnds, please can any one help me on this issue, it is very urgent . please help me ...... How to Transfer data from text file to .CSV format using C # code. Regards...
3
by: shigehiro | last post by:
Hi all, Further to my 'list of dictionaries' question yesterday, I would to ask how to write data to csv file format using 'list of dictionaries' as a source: data to be written to .csv file:...
2
Nert
by: Nert | last post by:
Hello there., i have this problem converting an flv video format to 3gp format using ffmpeg so that i can put the video on my cellphone. Well actually i have successfully converted the video to...
4
by: akhileshbyadav | last post by:
I was trying to capture entire web screen and save as .jpeg format. So far I have done this using C# Windows Application. Same thing I am willing to do in 'VC++ 2010 Win32. In my C++ project I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.