First off, let me just say that as someone with no DBA training
whatsoever, any help I can get with this issue will be very, very much
appreciated.
My company recently migrated our database from DB2 v7 to DB2 v9. We
hired a consultant to help us, and things went pretty smoothly ... up
until a few weeks after, when a co-worker tried to insert JavaScript
in to our database. That's when we learned that v9, unlike v7, has a
problem with statements such as this one:
INSERT INTO fake.table (fakeId, fakeJavaScript) VALUES (5555, '
function fakeFunction() {
doSomething1();
doSomething2();
}');
Back in v7, I could run "db2 -t", copy/paste that exact code, and the
new record would be created without issue. In v9 however, I find that
the database interprets the above as three separate statements:
#1
INSERT INTO fake.table (fakeId, fakeJavaScript) VALUES (5555, '
function fakeFunction() {
doSomething1();
#2
doSomething2();
#3
}');
Because it recognizes the semi-colon as a termination character even
though it is part of a string literal. This new behavior was
frustrating to discover, but what was even more frustrating was that
(even after I spent several hours Googling) I was unable to find any
way at all to reverse it. In fact, the only "solution" I was able to
find was "change your termination character".
Unfortunately, changing the termination character doesn't really solve
the problem, because I can't guarantee that the character I change it
to won't someday be used in a string literal (in fact, I can pretty
much guarantee the exact opposite; we use lots of weird characters).
Thus, the only real solution I can see is if I can find a way to tell
DB2 to let quotes trump termination characters.
Does such an option, or anything even close, exist? And if not, is
there perhaps some other way of resolving this issue that I haven't
considered? Of course, answers/suggestions would be great, but even
any further background information would really help me out.
Thanks,
Jeremy
whatsoever, any help I can get with this issue will be very, very much
appreciated.
My company recently migrated our database from DB2 v7 to DB2 v9. We
hired a consultant to help us, and things went pretty smoothly ... up
until a few weeks after, when a co-worker tried to insert JavaScript
in to our database. That's when we learned that v9, unlike v7, has a
problem with statements such as this one:
INSERT INTO fake.table (fakeId, fakeJavaScript) VALUES (5555, '
function fakeFunction() {
doSomething1();
doSomething2();
}');
Back in v7, I could run "db2 -t", copy/paste that exact code, and the
new record would be created without issue. In v9 however, I find that
the database interprets the above as three separate statements:
#1
INSERT INTO fake.table (fakeId, fakeJavaScript) VALUES (5555, '
function fakeFunction() {
doSomething1();
#2
doSomething2();
#3
}');
Because it recognizes the semi-colon as a termination character even
though it is part of a string literal. This new behavior was
frustrating to discover, but what was even more frustrating was that
(even after I spent several hours Googling) I was unable to find any
way at all to reverse it. In fact, the only "solution" I was able to
find was "change your termination character".
Unfortunately, changing the termination character doesn't really solve
the problem, because I can't guarantee that the character I change it
to won't someday be used in a string literal (in fact, I can pretty
much guarantee the exact opposite; we use lots of weird characters).
Thus, the only real solution I can see is if I can find a way to tell
DB2 to let quotes trump termination characters.
Does such an option, or anything even close, exist? And if not, is
there perhaps some other way of resolving this issue that I haven't
considered? Of course, answers/suggestions would be great, but even
any further background information would really help me out.
Thanks,
Jeremy
Comment