Results 1 to 6 of 6

Thread: Calling Oracle Stored Procedures with PHP

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    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.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    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 :

    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.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    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;
    /

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    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

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    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 :

    <?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";
    ?>

Similar Threads

  1. Extracting stored procedures
    By Maal-Gaadi in forum Software Development
    Replies: 3
    Last Post: 29-12-2010, 07:29 PM
  2. Using stored procedures and stored functions in MySQL
    By Adiran in forum Software Development
    Replies: 6
    Last Post: 14-12-2010, 01:54 AM
  3. What is SQL Stored Procedures?
    By technika in forum Software Development
    Replies: 5
    Last Post: 20-02-2010, 05:00 PM
  4. How to execute Stored procedures in Hibernate?
    By NegiRaj in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 11:54 PM
  5. Replies: 3
    Last Post: 03-08-2009, 09:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,648,541.74717 seconds with 17 queries