Pull Oracle CLOB different from VARCHAR2?

With MySQL, I can store large blocks of text in a TEXT column, pull, like any other type of column, no problem.

It seems that when I try to do the same with the CLOB on Oracle, I get errors.

Here where I pull:

<?php $comments = 'SELECT q2_other, q4_comments, q9_describe, q10, q11_comments, q12_describe, additional_comments FROM exit_responses WHERE sdate BETWEEN \'' . $start . '\' AND \'' . $end . '\''; $comments_results = oci_parse($conn, $comments); oci_execute($comments_results); while($row = oci_fetch_assoc($comments_results)){ if($row['Q2_OTHER'] != null){ echo '<div class="response">'; echo '<div class="info-bar">'; echo '<h5 class="date">' , date('F j, Y',strtotime($row['SDATE'])) , '</h5>'; echo ($_GET['names'] == 1) ? '<h5 class="name">' . $row['f_name'] . ' ' . $row['l_name'] . ' - ' . $row['title'] . ' - ' . $row['emp_type'] . '</h5>' : ''; echo '<div class="clear"></div>'; echo '</div>'; echo '<div class="comments">' , $row['q2_other'] , '</div>'; echo '<div class="clear"></div>'; echo '</div>'; } } ?> 

... and this is what I get when I try print_r () $ row in a while () loop:

 [Q2_OTHER] => OCI-Lob Object ( [descriptor] => Resource id #17 ) 

... (along with other columns in the query)

Is there anything special I need to do with CLOBS or my syntax is a bit off of it.

Thanks:)

+4
source share
2 answers

For LOB columns, OCI will return an OCI-Lob object that you must call load() or read(int bytes) to get the contents:

 $clob_contents = $row['Q2_OTHER']->load(); 
+5
source

or you can use the OCI_RETURN_LOBS flag, for example $row = oci_fetch_array($connection_id, OCI_ASSOC | OCI_RETURN_LOBS) to get a CLOB of type VARCHAR2:

$row['clob_field_name']

+3
source

All Articles