On Mon, Feb 22, 2010 at 3:58 PM, John Mcleod <[email protected]> wrote:
> I've done some research and I know that Oracle's datatype 'Clob' will
> hold the size but only at 4,000 chars. at a time.
> I'm just wondering how to do it?
I'm guessing you'll need to change the value into it's ready-to-store
binary format. Here's how I do it in PHP, perhaps you can port the
code:
function updateCLOBs( $table, $id, $keys, $values )
{
$count = count( $keys );
if( $count != count( $values ) )
die( "key and value counts don't match" );
for( $x = 0; $x < $count; $x++ )
{
$sql = "
UPDATE $table
SET $keys[$x] = EMPTY_CLOB()
WHERE id = $id
RETURNING $keys[$x] INTO :$keys[$x]
";
$query = OCIParse( $GLOBALS[ 'DBH' ], $sql );
$lob = OCINewDescriptor( $GLOBALS[ 'DBH' ], OCI_D_LOB );
OCIBindByName( $query, ":$keys[$x]", $lob, -1, OCI_B_CLOB );
OCIExecute( $query, OCI_DEFAULT )
or die( "Unable to execute query\n" );
if( !$lob->save( $values[ $x ] ) )
{
OCIRollback( $GLOBALS[ 'DBH' ] );
die("Unable to update lob\n");
}
OCICommit( $GLOBALS[ 'DBH' ] );
$lob->free();
OCIFreeStatement( $query );
}
return $id;
}
--
Greg Donald
destiney.com | gregdonald.com
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.