Folks,
I am having trouble select a CHAR column that has (') single quote in it
using perl. It is also a problem while running CLP from command line.
So I would prefer generic solution, but perl specific solution will also
work.
I am using DBI, DBD::DB2 modules.
Following is the fragment of the perlcode I am running:
---------cut-------------cut-------------cut-------------cut----
sub ExactSearchForSentence
{
my($String) = shift;
my($Language) = shift;
my(%Sentencehash) = ();
my($SqlStmt) = "SELECT RTRIM(SRC_NAME),RTRIM(SENTENCE)
FROM GBLCODE.SENTENCE S, GBLCODE.SOURCENAME N
WHERE S.SENTENCE = '$String'
AND LANGUAGE = '$Language'
AND S.SRC_NUM = N.SRC_NUM
FETCH FIRST 100 ROWS ONLY FOR READ ONLY";
print "DEBUG: $SqlStmt\n";
eval
{
$SqlStmtHdl = $DbHandle->prepare($SqlStmt);
$SqlStmtHdl->execute();
};
{
}
while(($FileName,$Sentence) = $SqlStmtHdl->fetchrow())
{
$Sentencehash{$FileName} = $Sentence;
}
$SqlStmtHdl->finish();
return(%Sentencehash);
$String = "This field is required if the 'transaction fee use code' is a '2'.";Quote:}
%SentenceHash = ExactSearchForSentence($String, 'EN1');
foreach $Key (keys %SentenceHash)
{
print "$Key\t[$SentenceHash{$Key}]\n";
---------cut-------------cut-------------cut-------------cut----Quote:}
When I run the perl script I get following error:
DEBUG: SELECT RTRIM(SRC_NAME),RTRIM(SENTENCE)
FROM GBLCODE.SENTENCE S, GBLCODE.SOURCENAME N
WHERE S.SENTENCE = 'This field is required if the 'transaction fee use code' is a '2'.'
AND LANGUAGE = 'EN1'
AND S.SRC_NUM = N.SRC_NUM
FETCH FIRST 100 ROWS ONLY FOR READ ONLY
lidp6|ExactSearchForSentence: DBD::DB2::db prepare failed: [IBM][CLI Driver][DB2/6000] SQL0104N An unexpected token "transaction" was found following "is required if the '". Expected tokens may include: "UNION". SQLSTATE=42601
In the above example I am setting $String in the code, but In actual program
it is passed from a Perl/TK program and it could come from different sources.
Here is the version of perl I am running on AIX 5.2.
# perl -v
This is perl, v5.8.0 built for aix-thread-multi
Copyright 1987-2002, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
Thanks.
--
Hemant Shah /"\ ASCII ribbon campaign
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.