Hi
I need to call a oracle function, but i need to bind one variable to get a value.
if a use php code and oci, i call the function:
$sql1="begin :RESULT :=WEBFUNCTION( ".
" price => 'S',".
" unit => 10 );end;";
$stmt=ociparse($conn,$sql1);
ocibindbyname($stmt,":RESULT",$result,50);
ociexecute($stmt);
At Drupal, with oracle:
db_set_active('oracle'); // set external database oracle
$stmt = db_query($sql1)->execute(); // execute function
db_set_active(); // set default internal database
I get error: "OCIStmtExecute: ORA-01008" because I don't bind the varible ":RESULT"
How i can bind that variable?
Can you help me?
Comments
Comment #1
aaaristo commentedyou can do somenthing like this... there are many examples of PDO::PARAM_INPUT_OUTPUT in the database.inc i think...
Comment #2
Anonymous (not verified) commentedThanks aaaristo!
But I have one problem, i change my code, and that error appears:
"Fatal error: Call to undefined method DatabaseStatementPrefetch::bindParam() in C:\wamp\www\project\includes\database\oracle\database.inc on line 632"
What am I doing wrong?
Comment #3
aaaristo commentedi changed the example above to use the DatabaseConnection_oracle::oraclePrepare method, because you need to go directly with PDO to do this.
You should add this method in database.inc:
Comment #4
Anonymous (not verified) commentedFantastic! Thanks!
I will change my code for test that solution, it will work!
One question, I'm doing a module, I can put
into my module?, for not change code of drupal core or contrib modules?
If it's possible, I need to change anything in that function?
Comment #5
aaaristo commentedyou should add it to the database.inc of the oracle module... i'll add it to the next release
Comment #6
aaaristo commentedin 1.10