Skip to content
Advertisement

call an Oracle function that do an insert/update from PHP?

we have a function if we call it by using SELECT we get the error code ORA-14551 “Cannot preform a DML operation inside a query”

JavaScript

how to run this function and get the results

when we run it in SQL developer in this way:

JavaScript

works with no errors

and we need this function to be called inside PHP

note: I can not paste this function here, because it’s to long, but it does allot of operations including insert and update!

Advertisement

Answer

A function that does DML cannot be called in a SELECT statement regardless of the calling language.

If you want to do DML and return a value, it would make much more sense to create a stored procedure with an OUT parameter rather than using a function. So it would make much more sense to

JavaScript

and then call that stored procedure from PHP

JavaScript

If you don’t want to do that, my guess is that you could do something like this as well (adapted from one of the scripts on page 164 of the Underground PHP and Oracle Manual)

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement