I have a stored procedure that populates a global temporary table.
1 2 3 4 5 |
|
I want to run a stored procedure and select rows added to a temporary table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
This code does not get any rows. So I decided to put the selection in the same round trip to the database:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
This gives me the error:
1 |
|
If I put the SELECT inside BEGIN ... END; then I get this error:
1 |
|
How to run a stored procedure in PHP that populates a temporary table and then selects from it?
It works in SQL Developer but not in PHP.
use:
1 2 |
|
P粉4329300812023-09-10 12:29:41
The first problem is that oci_execute()
defaults to commit, so any rows inserted by calling POPULATETEMPTABLE
will be cleared by ON COMMIT DELETE ROWS;
defined.
Fix this by changing to:
1 2 3 |
|
The second problem with putting a SELECT into a PL/SQL block is because this is invalid PL/SQL. Use reference cursors or implicit result sets. See the OCI8 documentation or the Underground PHP and Oracle Manual