Problem binding variables to Oracle statements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • final74

    Problem binding variables to Oracle statements

    Hi
    I'm experimenting with PHP5, ORacle 9i and ADODB and have run into
    problems trying to bind and output variable.

    I can make a successful connection to our database via the MSDAORA
    provider but the following simple statement will not work:

    $oCMD = new COM("ADODB.comm and");
    $oCMD->ActiveConnecti on = $dbConn; /// $dbConn generated
    earlier ...
    $oCMD->Prepared = True;

    $oCMD->CommandText = "SELECT 12345 INTO :num FROM dual";

    $oCMD->Parameters->Append($oCMD->CreateParamete r("num",adInteg er,adParamOutpu t,5));
    $oCMD->Execute();
    $ans = $oCMD->Parameters->Item("num")->Value;
    echo "answer: [$ans] <br />";

    This generates the following : answer: []

    I've tried binding via the '?' spaceholder as I've been told that
    can be used as well but it fails with the following:

    Fatal error: Uncaught exception 'com_exception' with message
    'Source: Provider
    Description: Unspecified error' ....

    Can anyone advise as to what I may be doing wrong with the above?
    Many thanks.

  • Andy Hassall

    #2
    Re: Problem binding variables to Oracle statements

    On 14 Dec 2005 05:52:12 -0800, "final74" <kev.grindley@g mail.com> wrote:
    [color=blue]
    >I'm experimenting with PHP5, ORacle 9i and ADODB and have run into
    >problems trying to bind and output variable.
    >
    > $oCMD = new COM("ADODB.comm and");
    >
    > Can anyone advise as to what I may be doing wrong with the above?[/color]

    Can't really help with the exact question, but why are you running through
    ODBC/ADO/COM when you could use the much better native Oracle support?
    Performance, portability and reliability will be better.

    In fact there's the (potentially confusingly named) ADOdb library (which has
    nothing to do with Windows' ADODB other than a vaguely similar interface) that
    does a good job of wrapping up the various PHP native database libraries into a
    consistent interface; I use it extensively on Oracle 9i.

    Download ADOdb for free. PHP database abstraction layer. ADOdb is a PHP database class library to provide more powerful abstractions for performing queries and managing databases. ADOdb also hides the differences between the different databases so you can easily switch dbs without changing code.


    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    Working...