Home » Open Source » Programming Interfaces » Passing Tables from PHP to PLSQL (PHP 5.0, Oracle 10g)
Passing Tables from PHP to PLSQL [message #279415] Thu, 08 November 2007 04:02
amcghie
Messages: 35
Registered: March 2005
Location: Sunny Dubai
Member
Hello all,

I have an existing database application that requires a "simple" front-end (are these things ever simple?). There is an existing API written which I would like to reuse if possible. Here is a snippet of the API:

TYPE property IS RECORD
  ( property_key   VARCHAR2(8)
  , property_value VARCHAR2(128) );

TYPE property_array IS TABLE OF property
  INDEX BY BINARY INTEGER;

PROCEDURE create_customer( i_customer_id IN customer.customer_id%TYPE
                         , i_properties  IN property_array )
IS
BEGIN
  ...
END create_customer;

In PHP I would like to call the create_customer procedure so would need something like:

<?php
...
// Set-up some dummy values
$cust_id    = 1
$properties = array( 'FNAME' => 'John'
                   , 'LNAME' => 'Smith'
                   , 'DOB'   => '01-JAN-2007' );

$conn = oci_connect("dev", "dev", "//localhost/XE");

$stmt = oci_parse($conn, 'begin create_customer(:cust_id, :properties); end;');

oci_bind_by_name($stmt, ':cust_id', $cust_id, -1, OCI_B_NTY);
oci_bind_array_by_name($stmt, ":properties", $properties, count($properties), -1, SQLT_CHR);
oci_execute($stmt);

This doesn't seem to work - I've RTFM but can't seem to find any doco on this (I've seem simple 1-dimensional array examples but nothing on 2D arrays). Is this even possible?

Any help would be gratefully appreciated!

Cheers

Andy
Previous Topic: retrieving CLOB from an Oracle stored function within perl
Next Topic: Perl Script To Call A Simple Oracle Stored Procedure
Goto Forum:
  


Current Time: Thu Mar 28 10:30:54 CDT 2024