Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Calling Oracle Stored Procedures with PHP

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-02-2010
Member
 
Join Date: Jan 2010
Posts: 56
Calling Oracle Stored Procedures with PHP
  

Hello !

I am a new guy, learning PHP and need to know the functionality of PHP with oracle where as I am so far from oracle but I get more enjoyed with oracle and willing to work with oracle database as a back end for my PHP applications. recently, I need to know about,how I would call particular procedure from the PHP code.

Your help would appreciated more...Thank you very much.

Reply With Quote
  #2  
Old 12-02-2010
Member
 
Join Date: May 2008
Posts: 2,383
Oracle Stored Procedures

Oracle Stored Procedures :

The oracle stored procedures is a program which resides physically in Oracle.The stored procedures are written through PL/SQL but now oracle introduced with some features which makes available you to create Oracle stored procedure with different languages like Java, .NET or other as External Procedures.

It is a group or series of relevant functionalities behind a single API.With this feature, the oracle procedures can be called with the help in PHP using some intellectual code.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 12-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Stored Procedure Input and Output with PHP

Stored Procedure Input and Output :

When you make a call to the procedure,all input and output data is passed as arguments to the procedure.This may be doubtful at first,if you will use the semantics of calling a PHP function with some arguments which returns a value as example shows :

Quote:
Computer_data (Order_count IN NUMBER, Values_Rs. OUT NUMBER)
When you call this procedure,the first argument Order_count would contain an input value which you pass during call and Values_Rs would be used as a return specifier attribute by the procedure upon the completion of procedure operation.
Reply With Quote
  #4  
Old 12-02-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
Calling Stored Procedures from PHP

Calling Stored Procedures from PHP :

According to the behavior of SQL statement,you use the statement under PHP codes and make a call to the procedure.You will nest the calls between the BEGIN ... END block which is also known as Anonymous block.
Like :
<?php
// etc.

$sql = 'BEGIN Computer_data(:Order_count, :Values_Rs); END;';


This statement will bind the variables with the PHP variables with calls to oci_bind_by_name().

If the sayHello procedure was defined by the following DDL statement:

Code:
CREATE OR REPLACE PROCEDURE 
        Computer_data (order_count IN INTEGER, Values_Rs OUT INTEGER) 
    AS
        BEGIN
            Values_Rs := 2,12000  || Order_count;
        END;
/
Reply With Quote
  #5  
Old 12-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,947
Calling Oracle Stored Procedures with PHP

Run the created script with the SQL*Plus command line and save the executed statement in the file with the identification name and login again.

$ sqlplus username@SID

Now create the procedure with the START command with the name of file :


SQL> START /home/username/Comp_pro.SQL
Reply With Quote
  #6  
Old 12-02-2010
Member
 
Join Date: May 2008
Posts: 2,007
Containing the codes to call Stored Procedures within PHP

Codes to call Stored Procedures within PHP :

You need to use the following script to call the procedure within PHP :

Quote:
<?php
$conn = oci_connect('HR','HR') or die;


$sql = 'BEGIN Computer_data(:Order_count, :Values_Rs); END;';

$stmt = oci_parse($conn,$sql);


oci_bind_by_name($stmt,':Order_count',$Order_count,32);


oci_bind_by_name($stmt,':Values_Rs',$Values_Rs,32);


$Order_count = 24;

oci_execute($stmt);


print "$......The Values would be following...\n";
?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Calling Oracle Stored Procedures with PHP"
Thread Thread Starter Forum Replies Last Post
Extracting stored procedures Maal-Gaadi Software Development 3 29-12-2010 06:29 PM
Using stored procedures and stored functions in MySQL Adiran Software Development 6 14-12-2010 12:54 AM
What is SQL Stored Procedures? technika Software Development 5 20-02-2010 04:00 PM
How to execute Stored procedures in Hibernate? NegiRaj Software Development 3 10-08-2009 11:54 PM
Is it a good practice of creating and using stored procedures for a database? Sentential Software Development 3 03-08-2009 09:13 PM


All times are GMT +5.5. The time now is 06:53 PM.