473,395 Members | 1,931 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,395 software developers and data experts.

How to insert special characters in psql?

I am having a file, that have to be inserted into db in text data type field. I am facing issue when the file having special characters like ( ,),. Kindly check the attached file for example.

Insert query only I have used.

Example:

Expand|Select|Wrap|Line Numbers
  1. obj=PGconn.connect(host,port'','',dbname,username,password")
  2. input="Last Cron Entry is = #50 23  * * *  /ProActive/bin/Logparser_NORTEL.pl -f /Zivah/Station/CTIServer/Nortel/logs/api_`date +\%d_\%m_\%Y`.log -a >> /RemoteTShooter/Out/Content/Nortel_Parser_logs_Reports_`/sbin/ifconfig | perl -ne 'if ( m/^\s*inet (?:addr:)?([\d.]+).*?cast/ ) { print qq($1_);}'``date +\%d\%m\%Y`;touch /RemoteTShooter/Out/Status/Nortel_Parser_logs_Reports_`/sbin/ifconfig | perl -ne 'if ( m/^\s*inet (?:addr:)?([\d.]+).*?cast/ ) { print qq($1_);}'``date +\%d\%m\%Y` smartctl -Hc /dev/sda
  3. ====================
  4. smartctl version 5.36 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen
  5. Home page is http://smartmontools.sourceforge.net/";
  6.  
  7.  
  8.  obj.exec("insert into hcoutputs (description) values('#{input}')")
Attached Files
File Type: txt file.txt (9.1 KB, 825 views)
Dec 8 '10 #1
1 15129
rski
700 Expert 512MB
I think the problem is with ' characters. The simplest solution is to double all ' characters in the string you want to insert to table.
Or you can escape the ' characters (writing \' instead of ') and use E operator like that
Expand|Select|Wrap|Line Numbers
  1. E'string you want to put into table'.
  2.  
If you choose the second solution you will have to escape \ characters too (you will have to write \\%d instead of \%d)
Dec 14 '10 #2

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

Similar topics

2
by: Paul | last post by:
Hi Doing my best to understand why I cant insert a vbcrlf or an equivalent into this piece of code that read messages from an SQL DB. The messages it takes read into a marquee fine but I want...
4
by: Doug Baroter | last post by:
Hi, This is a generic question, but for arguement's sake, let's say, my environment is SQL Server 2000. It seems that setting quoted_identifier off is the best way to accomodate all sort of...
9
by: Larry | last post by:
OK, I've been searching around the net for numerous hours and seem to just be getting more confused about handling special characters. In my host's configuration MagicQuotes is ON. (I understand...
3
by: Arielle | last post by:
Greetings! I'm using classic ASP and an insert statement to save bulletin messages to a database that can be updated or viewed later. At first I thought it worked perfectly so I took some sample...
4
by: den | last post by:
is there a complete list or for every nation with a special keyboard this can to change?
1
by: rshivaraman | last post by:
hi All : I have an insert statement which reads INSERT Into TableA (Col1) SELECT CASE WHEN Col1 LIKE '%%' THEN 999999 ELSE Col1 END AS Col1, FROM TableB
3
by: cheesecaker | last post by:
When I INSERT special characters into my MySQL database, they become distorted. For example, an accented e becomes "é". The database is set to utf8/utf8_general_ci, and so is the table and column...
6
by: TheRealDan | last post by:
Hi all. I'm having a problem with a special characters. I have php script that reads from an xml file and writes to a mysql db. It's a script called phptunest that I found on the net, although the...
2
by: Ravigandha | last post by:
Hello everybody, My question is how to insert special characters and symbols in Mysql5 database and how to retrieve them from database in php. Here i am inserting some data from a form,by post...
1
by: rajivkadam420 | last post by:
how to insert special characters into ms acess database along with text below is my example <!--#include file="common.asp"--> <!--#include file="header.asp"--> <% CheckAdminLogin if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.