Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
To Retrive clob datatype using oci funtions in php

Posted by vmk271 (vmk271), 8 April 2005
how to  get a clob datatype from oracle database using
oci functions? this is the sample i tried but couldnt get required data.


<?php
$strsql = '<request><subject><subjectattribute name="ID" datatype="number" value="47"/></subject><resources><resource objectID="report"><resourceattribute name="null" datatype="string" value="null"/></resource></resources></request>';
$objDBCommon = OCINLogon("usrname", "pwd", "domain");
$sql = "SELECT f_get_funct(to_clob('". $strsql."')).getClobVal() as LAY from ual";// passing a requset xml to oracle funtion f_get_funct

$statement = OCIParse($objDBCommon, $sql);
$success = OCIExecute($statement);
while ( OCIFetch($statement))
      {
       
         
        $lob = OCIResult($statement,1);
       
        $CLOB_MESSAGE = $lob->load();
        echo "data" . $CLOB_MESSAGE;
      }
OCIFreeStatement($statement);
  OCILogoff($objDBCommon);  
  $objDBCommon = NULL;
?>
pls help me

Posted by admin (Graham Ellis), 10 April 2005
I'm not an Oracle person so I've hung back to see if anyone eles would jump in here, but alas they haven't.  I've used MySQL blobs (that's similar) through PHP, sucessfully.   The thing I had to be careful of there was the encoding of the bit patterns that represent special characters like nulls and quotes - "addslashes" did the trick for me.

I hope this helps.   If not, please can you be more specific ("couldn't get required data" gets me asking "so what DID you get?").   And are you sure that you correctly have the data in the Oracle database in the first place?  Many's the time I've seen people trying to read data that's not there and getting very frustrated about it  

Posted by vmk271 (vmk271), 10 April 2005
Hi
  Thanks for your reply. The output i am expecting is a xml like this
<corp>
  <report permission="10">
   <abstract permission="4"/>
   <transfer permission="10"/>
   <summary permission="5"/>
   <billing permission="10"/>
   <annuity permission="0"/>
  </report>
</corp>

But the output t i got  is

object(OCI-Lob)#2 (1) { ["descriptor"]=> resource(11) of type (oci8 descriptor) }

Do i need to configure the php.ini file for getting clob data type?



Posted by admin (Graham Ellis), 10 April 2005
It looks to me like you're printing out some sort of object reference rather than the data the object contains, so I would guess you've got one missing method.  However, nothing obvious in the source code or manual page about that.

The page at php.net on ociresult http://uk2.php.net/manual/en/function.ociresult.php has an example that uses TO_CHAR within the select statement.   Might this be a good way to ensure you get the character (XML) string out?

The other possibility is that you've actually got the text that you printed out stored in the database ... so that the code you're showing me is correct but there's a problem with the insertion code.  I did ask in my last post if you're certain that you've got the right data in your database, but I don't see an answer in your latest post ...


Posted by vmk271 (vmk271), 11 April 2005
Thanks Graham for ur reply.

To answer ur question, Yes i have right data in the database. Finally I got the way to retrive the clob datatype from database. I am sending the code.

<?php

       $db = OCILogon("usrname","pwd");
       $sql = "SELECT f_get_funct(to_clob(:FOO)).getClobVal() as LAY from ual";
$stmt = OCIParse($db, $sql );
$strsql = '<request><subject><subjectattribute name="ID" datatype="number" value="47"/></subject><resources><resource objectID="report"><resourceattribute name="null" datatype="string" value="null"/></resource></resources></request>';
OCIBindByName($statement, ":FOO", $strsql);        
OCIExecute($stmt);

       while (OCIFetchInto($stmt,$arr,OCI_ASSOC)) {
                                   echo $arr[ "LOB" ]->load()."\n";
           }
   ?>




Posted by admin (Graham Ellis), 11 April 2005
Magic - glad it's sorted.  Thanks for following up and completing the thread

- Graham



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho