Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / May 2007

Tip: Looking for answers? Try searching our database.

Problem with CLOBS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
amitabh.mehra@gmail.com - 30 May 2007 05:37 GMT
Hi

I m new to DB2..

I am using DB2 version8. I have a few queries (which i create
dynamically) stored in a table. The column which stores them is clob
32k. Each of these query has a ":wf_id" string in 2 places, which i
replace with another string (using the replace function in sysfun pkg
in db2) before executing them. its something like:

DECLARE sqlString VARCHAR(32000);
For i as select dataValue from test_table
do
   SET sqlString = SYSFUN.REPLACE(i.dataValue, ':wf_id', 'abcdef');
--    PREPARE STMT from sqlString;
   EXECUTE IMMEDIATE strSql;
END FOR;

I get errors with this replace function... i guess, it does not work
fine with CLOBs in version 8 of DB2. Is there some work around other
than changing my column type to varchar(32000).

I have tried cast function also as in :

For i as select cast(dataValue as VARCHAR(32000)) dataValueChar from
test_table

The error in this case is that the query that comes in i.dataValueChar
is too long... this again happens with replace function. If i dont
replace and just assign it to sqlString, all works fine.. something
like:
     SET sqlString = i.dataValue;

Can someone please help me with this problem... or is there some other
way to run dynamic parameterized queries in db2 (with clob as a column
type).

Thanks in advance
Knut Stolze - 30 May 2007 09:33 GMT
> Hi
>
[quoted text clipped - 17 lines]
> fine with CLOBs in version 8 of DB2. Is there some work around other
> than changing my column type to varchar(32000).

Why?  REPLACE does support CLOBs:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/adm
in/r0000843.htm


$ db2 "values replace(clob('abcdef', 32000), 'cd', 'xy')"

1
-----------
abxyef

 1 record(s) selected.

So what exactly is the error that you got?

> I have tried cast function also as in :
>
[quoted text clipped - 3 lines]
> The error in this case is that the query that comes in i.dataValueChar
> is too long... this again happens with replace function.

What exactly is the error message that you got?

> If i dont
> replace and just assign it to sqlString, all works fine.. something
> like:
>       SET sqlString = i.dataValue;

Signature

Knut Stolze
DB2 z/OS Utilities Development
IBM Germany

amitabh.mehra@gmail.com - 30 May 2007 09:38 GMT
I get following error:
SQL0443N Routine "SYSFUN.REPLACE" (specific name "REPLACE2C") has
returned an error SQLSTATE with diagnostic text "SYSFUN:10"

> amitabh.me...@gmail.com wrote:
> > Hi
[quoted text clipped - 50 lines]
> DB2 z/OS Utilities Development
> IBM Germany
amitabh.mehra@gmail.com - 30 May 2007 10:20 GMT
It works fine when the length of the string-part that is to be
reaplaced (arg 2 of replace) is equal or greater than the new string
path (arg 3 of replace). If arg 3 is greater than arg 2 i am getting
this error. (sysfun:10)

On May 30, 1:38 pm, amitabh.me...@gmail.com wrote:
> I get following error:
> SQL0443N Routine "SYSFUN.REPLACE" (specific name "REPLACE2C") has
[quoted text clipped - 54 lines]
> > DB2 z/OS Utilities Development
> > IBM Germany
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.