Bind PL/SQL array to PHP array

Hi all!
I try to bind a PL/SQL array (nested tables, index by integer) returned by a PL/SQL-function to an PHP array.
Here is the code:
create or replace package MyPackage as
TYPE my_type IS TABLE OF VARCHAR2(1024);
FUNCTION MyFunction RETURN my_type;
end MyPackage;
create or replace PACKAGE BODY MyPackage is
FUNCTION MyFunction RETURN my_type IS
t_docs my_type;
begin
t_docs := my_type('val0','val1','val2');
return t_docs;
end MyFunction;
end MyPackage;
In the PHP-code ist looks like this
$query = "begin :vals := MyPackage.MyFunction; end;";
$stmt = oci_parse ($conn, $query);
oci_bind_array_by_name($stmt, ":vals", $vals_array, 5, 512, SQLT_CHR);
oci_execute ($stmt);
Output:
PLS-00382: expression is of wrong type. Error in Line....
This error point to
begin :vals := MyPackage.MyFunction; end;
^^^
Questions:
Is it generally possible to bind a pl/sql array to a php array? Or only the other was around?
Could you please post a snipet of code how to do it the right way :-)
Thanks a lot for your help! Christian

As you noted, you can't return a PL/SQL array and map it to a PHP array when it is a record type. Likewise, you can't map an object type to a PHP array. You can return a reference cursor through PL/SQL, and then fetch the function result with oci_fetch_assoc($rc).
Alternatively, you can return an object type collection or a pipelined table function result into PHP. It's a bit long but you'll find examples on my blog. Start here, and there's a link to a full discussion of pipelined table functions:
http://blog.mclaughlinsoftware.com/2009/03/19/beats-a-reference-cursor/
This is an object table example, which you may prefer over pipelined table functions:
http://blog.mclaughlinsoftware.com/2009/03/23/object-record-collections/
Hope this helps.

Similar Messages

  • How to store spry data in php array

    I am trying to store spry data in php array like this:
    <? $foo= array();?>
      <div spry:region="dsCALC">
        <div spry:repeat="dsCALC">
          <?php
    $foo[]='{dsCALC::DataPrice}';
    ?>
          </div>
      </div>
    <?var_dump($foo);?>
    Outputs:
    Array (     [0] => {dsCALC::DataPrice} )
    If I tried a variable, it works ok... The array, not... Any ideas?

    Outputs:
    Array (     [0] => {dsCALC::DataPrice} )
    And so it should, because that is what you told the PHP-script to do in the following line of code.
    $foo[]='{dsCALC::DataPrice}';
    Please remember that PHP code is handled on the server, whereas JavaScript (Spry) is handeld on the client (browser) end. JavaScript cannot be handeld by PHP nor can JavaScript handel PHP.
    My question to you is, why do you want to store the data in a PHP-array and how is the Spry data obtained?
    Ben

  • Passing Array to PHP

    Hi.
    I need to pass an array to php. But not by passing a string
    which will be split by a character (","). I was wondering if i can
    really pass an array to a php as an array not string.
    Thank you.

    You can pass arrays to PHP and from PHP to Flash if you use
    AMFPHP. It's a
    remoting replacement that I got hooked on long ago. It's most
    excellent.
    www.amfphp.org
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Import PHP-Array into Java-Application

    Hi!
    I want to call a PHP-Script from inside my Java-Application. The PHP-Script can return an array.
    How do I use a PHP-Array in Java and how do I import it????
    Thanks! =)

    thanks! =D
    one last question:
    -how would i have to change my example to make a
    https-connection?
    Did you try
    URL theURL = new URL("https://www.mysite.com/myscript.php");It works that simply. The only complication is if your server is set up for https or not. This is an Apache (or whatever webserver you are using)problem not a PHP problem.
    I think it gets upset if you try and use certificates with problems (self-signed etc) but not having tried this (I have only used it with certificates that are otherwise trustable) I don't know that for sure.
    Once upon a time I asked a question about using https as a client in Java and I got a variety of answers including doing mystic stuff with my keystore but I tried the simple and obvious and it works like a charm. At least from an Applet but I see no reason an application won't work the same way.
    Anyway try the simple and easy and see if that works for you. You might find that it does.

  • Send Array to PHP with HTTPService

    How can I send an array via HTTPService to a PHP script
    please?
    If I do this:
    var params:Object=new Objsect();
    params.myData=myDataArray; //myDataArray is an Array var that
    I need to send
    myService.send(params);
    It will not pass on an array.
    How can I pass the Array to PHP?

    u can convert the array in to a string in FLEX and in PHP u can use the "split" command...
    here s sample program see if it helps u
    http://flexarraytransfer.blogspot.com/

  • PHP-substract array from other array

    That should be simple, yet I can't find a simple solution...
    I have two multidimensional arrays, for example:
    FIRST ARRAY:
    Array
    [0] => Array
    [0] => Ring
    [1] => 20.00
    [1] => Array
    [0] => Bracelet
    [1] => 75.00
    [2] => Array
    [0] => Bracelet
    [1] => 75.00
    and SECOND ARRAY:
    Array
    [0] => Array
    [0] => Bracelet
    [1] => 75.00
    Note that in the first array, [1] and [2] are the same, and
    in the second array, [0] is equivalent
    to both [1] and [2] in the first array.
    Basically I want to SUBSTRACT second array from first array,
    regadless of key order, that is, i want
    to remove ONE
    [0] => Bracelet
    [1] => 75.00
    from first array.
    So that the resulting array will be:
    Array
    [0] => Array
    [0] => Ring
    [1] => 20.00
    [1] => Array
    [0] => Bracelet
    [1] => 75.00
    I have looked the array functions at php.net, but I have not
    seen a function that does that, or did
    not realize i saw it if i did.
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    An Ingenious WebSite Builder:
    http://sitelander.com

    ok i did what i wanted it with a foreach loop and a little
    trickery...
    still curious to know if there is a one-line ready-made php
    function for that though...
    (_seb_) wrote:
    > That should be simple, yet I can't find a simple
    solution...
    >
    > I have two multidimensional arrays, for example:
    >
    > FIRST ARRAY:
    > Array
    > (
    > [0] => Array
    > (
    > [0] => Ring
    > [1] => 20.00
    > )
    >
    > [1] => Array
    > (
    > [0] => Bracelet
    > [1] => 75.00
    > )
    > [2] => Array
    > (
    > [0] => Bracelet
    > [1] => 75.00
    > )
    > )
    >
    > and SECOND ARRAY:
    > Array
    > (
    > [0] => Array
    > (
    > [0] => Bracelet
    > [1] => 75.00
    > )
    >
    > )
    >
    > Note that in the first array, [1] and [2] are the same,
    and in the
    > second array, [0] is equivalent to both [1] and [2] in
    the first array.
    >
    > Basically I want to SUBSTRACT second array from first
    array, regadless
    > of key order, that is, i want to remove ONE
    >
    > [0] => Bracelet
    > [1] => 75.00
    >
    > from first array.
    >
    > So that the resulting array will be:
    >
    > Array
    > (
    > [0] => Array
    > (
    > [0] => Ring
    > [1] => 20.00
    > )
    >
    > [1] => Array
    > (
    > [0] => Bracelet
    > [1] => 75.00
    > )
    > )
    >
    > I have looked the array functions at php.net, but I have
    not seen a
    > function that does that, or did not realize i saw it if
    i did.
    >
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    An Ingenious WebSite Builder:
    http://sitelander.com

  • PHP & array processing

    Hello,
    Can PHP process more rows in ocifetch ?
    regards

    I did a little testing on Windows 2000 using SQL*Plus and client
    libraries from Oracle 9.2. The DB was a 9.2 release on a remote
    machine.
    The SQL script was:
      connect scott/tiger@mydb
      define AS = 1
      prompt Arraysize &AS
      set arraysize &AS
      set pagesize 0
      set linesize 200
      set termout off
      spool c:\temp\bmsp.log
      timing start
      select * from all_objects order by 1;
      spool off
      set termout on
      timing stopThe PHP file was:
      <?php
      require("ScriptTimer.php");  // from user comments on "microtime" man page
      $pfrc = 1;
      $filename = "c:/temp/bmphp.log";
      $conn = OCILogon('scott', 'tiger', 'mydb');
      Script_Timer::Start_Timer();
      if (!$handle = fopen($filename, 'w')) {
        echo "Cannot open file ($filename)";
        exit;
      $query = 'select * from all_objects order by 1';
      $stid = OCIParse($conn, $query);
      OCIExecute($stid);
      OCISetPrefetch($stid, $pfrc);
      while ($succ = OCIFetchInto($stid, $row)) {
        foreach ($row as $item) {
          fwrite($handle, $item." ");
        fwrite($handle, "\n");
      fclose($handle);
      $total_time = Script_Timer::Get_Time(3);
      echo "$pfrc Time was $total_time\n";
      ?>SQL*Plus 9.2 results:
       Time   Arraysize        
       2.1    1000             
       2.1    500              
       2.1    250              
       3.0    100              
       3.0    50               
       4.1    10               
       9.1    1                 PHP (CLI) 4.3.4 results:
       Time   Prefetchrowcount
       4.5    1000           
       4.5    500            
       4.6    250            
       4.7    100            
       4.8    50             
       5.7    10             
       9.2    1               This was a pretty rudimentary benchmark. There are a lot of areas of
    difference between SQL*Plus and PHP that could be debated and
    examined.
    Overall I'm comfortable that PHP's prefetchrowcount has a positive
    effect.
    -- CJ

  • Can't figure out how to install sql server for PHP

    I am trying to install SQL Server for PHP on a server with Server 2008 32 bit.  The exe from http://www.microsoft.com/en-us/download/details.aspx?id=20098 keeps tell me that it is an invalid win32 application.  I've tried running as administrator
    as well.  Somewhere I read you need to open the exe with 7zip.  I was able to do that and see all the files in there, but where do I go from there?
    Thanks
    Mike
    edit: forgot to mention I'm using Apache for my server

    That solution is obsolete. The current solution is here:
    http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
    bill ross

  • Array pointer in array

    Can anybody tell me how to create pointers in an array pointing to other arrays?

    RichL wrote:
    Hi tbob,
    thanks for your suggestion! I did build it up with three arrays and a numeric control to select one of the arrays, which works fine. However, there are the following effects which I don't understand yet.
    1. The RefArray can only be defined as Variant, showing a violet colour instead of a green/blue as in your example; I could not find a refnumber without giving me an error.
    2. By changing the array selector, following array elements are being written into: 1,1 of array0; 0,0 of array1 and 1,0 of array2. I don't see why it is different for each array. Is there a possibility to select the array element being written into?
    My VI is attached, LV7.1
    Kind regards
    Richard
    Strange, when I created my vi, the RefArray was blue-green, not a Variant.  On the front panel I placed a blank array.  Then I placed a Control Refnum into the array.  Now the array is defined as a Control Refnum Array, not a Variant.
    Attached is a vi similar to the picture I had previously attached.  In your case, you would need a slightly different method because of your unknown quantities of channels for each source.  The use would select a source, and then you would have to retrieve an array of channels for that source.  The user then selects a channel, and you would have to retrieve the data for that channel.
    Post what you have so far so that we can look at it.
    - tbob
    Inventor of the WORM Global
    Attachments:
    RefArray.vi ‏50 KB

  • Can't duplicate movieclips as an array within an array

    Hello.
    I have an animation that loads an xml into it and traces back
    an array within an array. I have tried to apply this to duplicated
    movieclips thereby creating a structured set of links. What I am
    trying to do is this:
    Chicken Nuggets
    __Compression
    __Texture
    __Disgust
    Mega Warhead
    __Taste
    __Hardness
    __Pain
    This traces fine but I can't seem to get the duplicated
    movieclips to assemble in this fashion.
    The code for the XML is as follows:
    var controlArray:Array;
    var variable:Array;
    var testTopic = new Array ();
    var test = new Array ();
    var controlsXML:XML = new XML();
    controlsXML.ignoreWhite = true;
    controlsXML.onLoad = function(success:Boolean){
    if (success){
    var mainnode:XMLNode = controlsXML.firstChild;
    var controlNodes:Array =
    controlsXML.firstChild.firstChild.firstChild.firstChild.childNodes;
    var list:Array = new Array();
    for (var i:Number = 0; i < controlNodes.length; i++) {
    var personnode:XMLNode = controlNodes
    .attributes.Name;
    trace(personnode);
    testTopic.push (new struct (personnode));
    var specificNode:Array = controlNodes.childNodes;
    for (var j:Number = 0; j < specificNode.length; j++){
    var itemnode:XMLNode = specificNode[j].attributes.Variable;
    trace(itemnode);
    test.push (new struct2 (itemnode));
    printer ();
    printer2 ();
    } else {
    trace('error reading XML');
    controlsXML.load ("controls3.xml");
    The code for the movieclip duplication is as follows:
    x = 50;
    function printer ()
    for (m = 0; m < testTopic.length; m++)
    duplicateMovieClip ( slotTopic, "slotTopic" + m, m );
    slotTopic = eval ( "slotTopic" + m );
    slotTopic._y += x;
    slotTopic.slotTopicContent.text = testTopic[m].personnode;
    function printer2 ()
    for (k = 0; k < test.length; k++)
    duplicateMovieClip ( slot, "slot" + k, k );
    slot = eval ( "slot" + k );
    slot._y += x;
    slot.slotContent.text = test[k].itemnode;
    function struct (personnode)
    this.personnode = personnode;
    function struct2 (itemnode)
    this.itemnode = itemnode;
    On the stage are two movieclips, titled "slotTopic" and
    "slot". Within those are dynamic text boxes titled respectively
    "slotTopicContent" and "slotContent". When I preview this file it
    only displays the text within the "slot" movieclip and it lists all
    six of the subtopics with no break. So, there are two dilemmas:
    1) The movieclips won't duplicate into the structured set of
    links that I want.
    2) "slotTopic" is not displaying text at all.
    If anyone has any advice, I'd really appreciate it.
    Thx!

    ok, I'm sorry but there are quite a few things wrong here.
    first though, when posting code please use the 'attach code'
    button.
    1) i can't imagine that you have a XML structure as deep as
    your calling to or the need for it with the limited amount of
    infomation your pulling, in addition your storing the info in
    attributes, so I can't see how this would work, it may 'trace' out
    the right text (somehow) but it's not getting into the arrays
    properly.
    2) you do not assign an attribute value to a XMLNode, and
    then try to push it into an array.
    3) you do not call a method (struct or struct2) using the
    'new' operator. this is how you envoke a new 'class' instance.
    4) do not use 'x' as a variable name as it is a reserved var
    in flash, assigned to an Object instance.
    5) the duplicateMovieClip() method needs to be called upon
    the existing clip as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m);
    additionally you can pass the _y placement within the
    initObject.
    6) you do not need to use eval, it isn't doing anything here,
    you will gain the correct path by calling duplicateMovieClip
    correctly.
    7) the reason why slotTopic is not being displayed at all is
    because of the second loop, you are duplicating the clips
    (incorrectly) into the same depths thereby replacing all of the
    contents of the slotTopic depths previously constructed.
    the solution to this problem is to construct both items with
    the same loop but increament one of the depth assignments by a
    specific number, in other words at depths much higher or at least
    different, than that of the first element, as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m, {_y:50});
    slot.duplicateMovieClip('slot'+(m+100), m+100, {_y:50});
    again I'm sorry man, but it will take some work to sort this
    out.

  • Mapping vertical arrays versus horizontal arrays in HP exstream

    Anyone with details on mapping vertical arrays versus horizontal arrays in HP Streak software please?

    johnsold wrote:
    Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
    I agree, this looks inconsistent.
    Ranjeet_Singh wrote:
    Make the index of both the array 0 then run your program. 
    Now horizontal array shows 4th element & vertical array shows 10th element. 
    What are you trying to say here? You are just repeating the instruction #1 on the front panel of the posted VI, then repeating what the image above already shows.
    LabVIEW Champion . Do more with less code and in less time .

  • Assigning javascript array with jsp array

    hi,
    I have a jsp page where I have a array in jsp. I want to assign the values to an javascipt array. how can I do that?
    the reason why I want to do this is for a perticular problem I am facing in javascript. that is....
    I have a text box in my jsp page, I want the value entered in that box to be checked (whether it exists ) against a hidden string which has some value. I want that hidden string not to be shown to the user even on seeing the html source. that is why I want these values to be stored and checked against a array object of javascript.
    any suggestion is appreciated
    Thanks
    Ashutosh

    Hai asutoshdash
    if you dont mind of viewing code u can use this else dont use, its not matters weatehr user will see you code or not if the user is professiona then its a big issue normal users not think of is for this dont send valuable infos like password etc to client u may send usernames
    ok to create a java array to javascript array do this (i took example of db to array ) write this inside <script> <%codes here%> </script>
    var aUsername =new array();
    <%
    int i=0;
    while (rs.next())
    %>
    aUsername[<%= ++i%>] = "<%= rs.getString("User_Name")%>";
    <%
    %>thats it use this array where ever you want in your client side(javascript ) usage
    hope this will help you
    archi

  • Array inside another array

    hi guys
    is it posible to place one array inside another array?
    something like
    public double[] dblarray(int n)
    double [] dbl2 = new double(n)
    return dbl2;
    public double[] dbl2array(int m,int n)
    int n=10
    double [] dbl2 = new dobule[m];
    for(int i = o;i < m ; i++)
    dbl1=dblarray(n)
    if tryed it an it told me its wrong. does any one know how to do it or if it is posible since i come from ansi c i know this is posible in c but is it in java???
    pleas help:)
    thanks
    jeliel

    No, it's not possible in a strict sense. Java is more type safe than C - in C there is no real array type...
    What you can have is an array of references (=pointers) to arrays of doubles, or double[][], and what your code does is more commonly written asdouble[][] dbl2 = new dobule[m][10];

  • Cast Object Array to String Array.

    When I try to cast an object array to string array an exception is thrown. How do I go about doing it?
    Vector temp = new Vector();
    Object[] array = temp.toArray();
    String[] nonterms;                              
    nonterms = (String[])array;
    Thanks,
    Ally

    Try this
    import java.util.Vector;
    public class Test
         public static void main(String args[]) throws Exception
              Vector v = new Vector();
              v.add("a");
              v.add("b");
              v.add("c");
              Object[] terms = v.toArray();
              for(int i = 0; i < terms.length; i++)
                   System.out.println((String)terms);
    Raghu

  • Converting an array to an array collection

    When converting an array to an array collection, is it good
    practice to remove the original array? If so, how does one do
    that?

    My 2 cents - I think it may be unnecessary. The garbage
    collector should notice a lack of references to the original array
    and delete it for you.

Maybe you are looking for

  • Mailing .pdf attachments to Presto Printer doesn't work with Firefox but does with IE, how can I fix this?

    Since upgrading to 4.0.1 the email address [email protected] indicates that there is something wrong with any attachment in .pdf format. This happens when I send mail from my yahoo or aol mail accounts when using Mozilla. It does not occur if I'm usi

  • Outlook Shared Contacts Sync Issue

    **Before i start, i posted this in the Outlook section and was told to post it the Outlook for Exchange section.. So i posted this in the Outlook for Exchange section and the Moderator tells me to post it in the Outlook section.. So i'm being thrown

  • Modify list view - Group by Lookup column's ID

    Hi I have a main list that has a lookup column. The grouping works fine, but I want the sort order of the group to appear as the way the lookup value's ID is ... What are the ways to achieve this, I do not want to put a number in front of the values,

  • Display two characteristics in the same column

    Hi everyone, I have two cubes that store key figures in two different ways. In the first cube I have several key figures like "Amount in Local Currency", "Amount in Document Currency" etc. these have the currency characteristics  "Local currency"(0LO

  • Help with installing flash player

    Hi...I'm so confused on this thing here. I've installed this more than 5 times now. First I'll mention that I needed this because I enter a contest daily and it called for this download. Now I also clean my computer regularly and after I do clean my