ora_bind - what does it do?

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

    ora_bind - what does it do?

    Hi everyone

    Can anybody give me a decent explanation of what ora_bind is supposed to do?

    I assumed it did the same sort of thing as Perl's DBI bind_columns function
    ie. as each column is returned from a $statement_hand le->execute, it assigns
    the returning values to the Perl variables eg [note this is Perl]:

    $sql = select netware_id, windows_user_id , exchange_id, machine_name,
    ip_address, context, running_on, to_char(created ,'yyyy-mm-dd')
    from mail
    my $sth = $dbh->prepare($sql ) || Carp::croak $dbh->errstr." - PREPARE\n";
    $sth->execute || Carp::croak $dbh->errstr." - EXECUTE\n";
    $sth->bind_columns(\ $netware_id, \$windows_id, \$exchange_id,
    \$machine_name, \$ip_address, \$context, \$os, \$created);
    while ($sth->fetchrow_array ref) {
    .... in this while loop, $netware_id will be set to the first returning
    value, $windows_id to the second etc....

    I tried this in PHP a follows:

    $handle = ora_plogon($set tings['OraUser'], $settings['OraPass']) or
    die("Can't connect");
    $cursor = ora_open($handl e) or die("<b>Error - can't execute $cursor");
    $sql = "SELECT :machine_name, :exchange_id
    FROM MAIL
    where ....
    ";

    ora_parse($curs or, $sql) or die("Can't parse $sql");

    ora_bind($curso r, "machine_na me", ":machine_name" , 20) or die("Can't bind
    machine_name");
    ora_bind($curso r, "exchange_i d", ":exchange_ id", 30) or die("Can't bind
    exchange ID");

    ora_exec($curso r) or die("<b>Execute : ".ora_errorcode ($cursor));

    while(ora_fetch ($cursor)) {
    ....

    but I just get:
    Warning: Can't find variable for parameter in
    /export/apache/htdocs/ecensus.nat.bt. com/test2.php on line 19
    Execute: 0

    I can achieve what I'm after by using ora_getcolumn but am interested to
    know why I can't seem to bind variables.

    Could somebody tell me if I'm completely mistaken in thinking that PHP's
    ora_bind function is completely different than Perl's bind_columns? IMO
    either the PHP manual's ora_bind example needs simplifying or it needs to be
    explained more clearly what the function does.

    cheers
    Rob


Working...