I'm just using the cfquery tag and selecting the CLOB column like I would any other column. The difference here is that if you do a cfdump of the query results you'll notice that the CLOB column contains an object rather than a text value. I setup the following UDF to extract the value of the CLOB and output it:

<cffunction name="CLOBtoString" output="false" returntype="string">
<cfargument name="clobObject" type="any" required="true">
<cfscript>
var returnString = "";
try
{ returnString = clobObject.getSubString(1,clobObject.length());
}
catch (Any e)
{
returnString = "Error converting CLOB to String.";
}
return returnString;
</cfscript>
</cffunction>


You just pass the function your query.clobfieldName variable and it returns the contents as a string (NOTE: I believe the way I'm doing the conversion does limit the length of my CLOBS to be the max size of an integer, but that is way bigger than I'll ever need with this app.)

Interestingly if you use the cfquery tag to select a CLOB field you cannot call the object methods like this: myquery.clobField.getSubString(10). That just gave me an error. I had to first assign the field to a new variable and then call the methods like this:

<cfscript>
   clobF = myquery.clobField;
   clobF.getSubString(10);
</cfscript>


---------------------------------------------

Could you share a code example of how you "returned the CLOB object"
and "used getSubString function"?  Are you accessing the query as a Java
ResultSet?

Thanks,
Jon

>>> [EMAIL PROTECTED] 10/11/2004 1:57:10 PM >>>
Turns out that the inserts/updates were working fine but when I went to

select the value of a CLOB column that was longer than 4000 it was
getting truncated.  Rather than using the TO_CHAR function in my select

I now just return the Oracle CLOB object and use the getSubString
function to pull out all of the contents of the CLOB.

Thanks for everyone's suggestions on this.

Stephen

Stephen wrote:

> I'm curious what approach people use for persisting objects in the
> db.  Let's say I have a Person object.  Is it better to have that
> Person object contain all of the Business methods to work on the
> object as well as the methods to persist itself or is it better to
set
> up a separate PersonDAO object that deals with all of the database
> interactions and keep all database interaction out of the Person
object?
>
> Along those lines, I'm also curious how people actually do their
> updates.  Do you first update all of the properties of an object and

> then call a Persisit() method or when a setter method is called do
you
> have it update the object property and then update that property in
> the db?  Seems like a lot of extra db traffic to do it the second way

> but it would cut down on some persistance logic.
>
> I'm still a little new at working with CFCs in a more OO way so any
> help would be greatly appreciated.
>
> Stephen
>


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to