Discussion:
inserted values to be structured in the specified format
(too old to reply)
v***@miraclesoft.com
2007-08-01 09:15:04 UTC
Permalink
Here is a table structure :

Column Type Type
name schema name Length Scale Nulls

EMPNO SYSIBM INTEGER 4 0 Yes

ENAME SYSIBM CHARACTER 20 0 Yes

CNTY_VISITED SYSIBM CHARACTER 100 0 Yes

Now goes the prob.....

I want to insert a row in the table such that the data in the table shud look as :

EMPNO ENAME CNTY_VISITED
1001 JACK 'IND','JPN'

I guess you understood the req. It should not be IND,JPN.. It should be ' IND ' , ' JPN '
in the table.
Andreas Kannegiesser
2007-08-01 10:31:56 UTC
Permalink
Post by v***@miraclesoft.com
Column Type Type
name schema name Length
Scale Nulls
EMPNO SYSIBM INTEGER 4
0 Yes
ENAME SYSIBM CHARACTER 20
0 Yes
CNTY_VISITED SYSIBM CHARACTER 100
0 Yes
Now goes the prob.....
I want to insert a row in the table such that the
EMPNO ENAME CNTY_VISITED
1001 JACK 'IND','JPN'
I guess you understood the req. It should not be
IND,JPN.. It should be ' IND ' , ' JPN '
in the table.
Hi,

if your problem is to insert a single quotation mark character (') into a column in a DB2 table, then you could simply double that character in your insert statement like so:

INSERT INTO <table> VALUES (1001, 'JACK', '''IND'',''JPN''')

Good luck
aka.
Knut Stolze
2007-08-02 09:47:10 UTC
Permalink
Post by Andreas Kannegiesser
Post by v***@miraclesoft.com
Column Type Type
name schema name Length
Scale Nulls
EMPNO SYSIBM INTEGER 4
0 Yes
ENAME SYSIBM CHARACTER 20
0 Yes
CNTY_VISITED SYSIBM CHARACTER 100
0 Yes
Now goes the prob.....
I want to insert a row in the table such that the
EMPNO ENAME CNTY_VISITED
1001 JACK 'IND','JPN'
I guess you understood the req. It should not be
IND,JPN.. It should be ' IND ' , ' JPN '
in the table.
Hi,
if your problem is to insert a single quotation mark character (') into a
column in a DB2 table, then you could simply double that character in your
INSERT INTO <table> VALUES (1001, 'JACK', '''IND'',''JPN''')
And if you do this from an application, just use parameter markers (good
against SQL-injection problems). Then the string can contain a single-quote
and you don't need to escape it by doubling it.
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Loading...