Jump to content

PHP/Oracle Procedure


Recommended Posts

Hello there,

Ok - Something a bit new for me. I am currently working on a site that uses PHP & Oracle. We have built a procedure where we need to.

Input:

  • Login ID Number (PHP Variable)
  • Current Server Date (sysdate in Oracle)

 

Output:

  • A list of messages from the Server

 

The Oracle side works & is tested. However we are getting problems when using the code:

$conn = OCILogon("****","****","****"); 
$curs = OCINewCursor($conn); 
$stmt = OCIParse($conn,"begin DISPLAY_MSG(_login_id, _date, _msg); end;"); 

OCIBindByName($stmt,"_login_id",&$gid,32);

OCIBindByName($stmt,"_msg",&$curs,-1,OCI_B_CURSOR); 

//$gid=1; // for gid = 1 only
//ociexecute($stmt); 
//ociexecute($curs); 

//while (OCIFetchInto($curs,&$friend_cv )) { 
//   echo "<pre>"; 
//    print_r($P_msg); 
//   echo "</pre>"; 
//} 

OCIFreeStatement($stmt); 
OCIFreeCursor($curs); 
OCILogoff($conn); 

 

However - I am stumped! I really don't know where to start, and need to know how to act with the procedure (input & output) and whether I can just use sysdate as the date.

 

Regards,

Matt

Link to comment
https://forums.phpfreaks.com/topic/160893-phporacle-procedure/
Share on other sites

Ok,

Im going somewhere now. My code looks like follows:

$ses_username = $sucid;
$ses_date = date('Y-m-d H:i:s',time());
$conn = OCILogon("user","password","server"); 
$curs = OCINewCursor($conn); 
$stmt = OCIParse($conn,"begin DISPLAY_MSG('$ses_username', '$ses_date', _msg); end;"); 

OCIBindByName($stmt,"_msg", &$ses_username, &$ses_date 20) or die ('Can not bind variable');  

OCIFreeStatement($stmt); 
OCIFreeCursor($curs); 
OCILogoff($conn); 

 

However I just get a blank screen, as soon as I comment OCIBindByName out it all works again.

 

Regards,

Matt

Link to comment
https://forums.phpfreaks.com/topic/160893-phporacle-procedure/#findComment-849105
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.