473,405 Members | 2,349 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,405 software developers and data experts.

Escaping semicolon embedded in string values in db2sql92

Friends,

I'm using db2sql92 to execute an SQL script that is performing
an insert operation on a table in a DB2, version 8.2 database server.

The string value contains embedded semicolon characters, and I can't
figure out how to escape these. Here is a sample statement:

INSERT INTO mytable VALUES(1, 'opt1;opt2;opt3');

This fails with an error that the String 'opt1' is not properly
terminated:
Statement # 1 :
insert into mytable VALUES (1, 'opt1

SQL0010N The string constant beginning with "'opt1" does not have an ending
string delimiter. SQLSTATE=42603


I've tried various ways of escaping the semicolons, but can't find the
magic rule. I've looked in the DB2 SQL reference manuals, as well as
the documentation on the db2sql92 utility, but no clues.

How do I do this?

By the way, I'm using db2sql92 only because it is the only tool
I've found to execute SQL scripts. Is there a better command-line
utility that I should be using? I've found a number of silly
problems with this tool (like the one above) that make me think
it may be old and no longer kept up to date.
--
Mark Hansen
Sacramento, CA
Nov 12 '05 #1
2 9991

"Mark Hansen" <me*@NOSPAMunify.com> wrote in message
news:11*************@corp.supernews.com...
Friends,

I'm using db2sql92 to execute an SQL script that is performing
an insert operation on a table in a DB2, version 8.2 database server.

The string value contains embedded semicolon characters, and I can't
figure out how to escape these. Here is a sample statement:

INSERT INTO mytable VALUES(1, 'opt1;opt2;opt3');

This fails with an error that the String 'opt1' is not properly
terminated:
Statement # 1 :
insert into mytable VALUES (1, 'opt1

SQL0010N The string constant beginning with "'opt1" does not have an ending string delimiter. SQLSTATE=42603


I've tried various ways of escaping the semicolons, but can't find the
magic rule. I've looked in the DB2 SQL reference manuals, as well as
the documentation on the db2sql92 utility, but no clues.

How do I do this?

By the way, I'm using db2sql92 only because it is the only tool
I've found to execute SQL scripts. Is there a better command-line
utility that I should be using? I've found a number of silly
problems with this tool (like the one above) that make me think
it may be old and no longer kept up to date.
--
Mark Hansen
Sacramento, CA


I am not sure about db2sql92 but when using the DB2 command line, most
people use:

db2 -td@ -vf file-name

You just replace the legitimate semi-colons with an "@".
Nov 12 '05 #2
On 2/18/2005 14:32, Mark Hansen wrote:
Friends,

I'm using db2sql92 to execute an SQL script that is performing
an insert operation on a table in a DB2, version 8.2 database server.

The string value contains embedded semicolon characters, and I can't
figure out how to escape these. Here is a sample statement:

INSERT INTO mytable VALUES(1, 'opt1;opt2;opt3');

This fails with an error that the String 'opt1' is not properly
terminated:
Statement # 1 :
insert into mytable VALUES (1, 'opt1

SQL0010N The string constant beginning with "'opt1" does not have an ending
string delimiter. SQLSTATE=42603
I've tried various ways of escaping the semicolons, but can't find the
magic rule. I've looked in the DB2 SQL reference manuals, as well as
the documentation on the db2sql92 utility, but no clues.

How do I do this?


Well, after reading the SQL 92 ANSI specification, I found that
I could do this:

'opt1' CONCAT X'3B' CONCAT 'opt2' CONCAT X'3B' CONCAT 'opt3'

which worked.

I'm still interested in a better command-line tool than db2sql92.

Thanks,


By the way, I'm using db2sql92 only because it is the only tool
I've found to execute SQL scripts. Is there a better command-line
utility that I should be using? I've found a number of silly
problems with this tool (like the one above) that make me think
it may be old and no longer kept up to date.

--
Mark Hansen, PP-ASEL
Sacramento, CA
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dave Moore | last post by:
Hi All, Can anybody point me to a FAQ or similar that describes what all this stuff is about please?. I'm interfacing with a MySQL database if that's relavent. I've read a couple of books which...
14
by: Ian Rastall | last post by:
Sorry for the double question. I'm having a terrible time figuring out how to escape apostrophes in my mySQL database. Perhaps they have to be escaped in the PHP, using mysql_real_escape_string? ...
3
by: Jane Doe | last post by:
Hello, I need to browse a list of hyperlinks, each followed by an author, and remove the links only for certain authors. 1. I searched the archives on Google, but didn't find how to tell the...
5
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore...
3
by: Dan | last post by:
I'm writing a record from an asp.net page to SQL Server. After the insert I'm selecting @@identity to return the ID of the record that I just wrote. It worked fine until I typed a semicolon into...
11
by: Geoff Caplan | last post by:
Hi folks, The thread on injection attacks was very instructive, but seemed to run out of steam at an interesting point. Now you guys have kindly educated me about the real nature of the issues,...
0
by: Michael Rudolph | last post by:
Hi newsgroup, I try to connect to a host db2 (DB2 OS/390 7.1.2) from my db2 client on windows (DB2/NT 8.2.3). Using interactive mode everything works fine (db2, connect to abc user x using y,...
3
by: Greg R. Broderick | last post by:
Y'all: I am needing some way, in the SQL Server dialect of SQL, to escape unicode code points that are embedded within an nvarchar string in a SQL script, e.g. in Java I can do: String str =...
6
by: Nick | last post by:
Hi all, Is this expected behavior? '123\\;abc' I just wanted a single backslash. I can see why this probably happens but i wondered if it is definitely intentional. Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.