Frage

I am using PHP PDO. My stored procedure returns two result sets. Is it possible to name the result sets? In case they are SELECT statements on two tables like,

SELECT * FROM A

and

SELECT * FROM B 

Is it possible to identify them?

War es hilfreich?

Lösung

No, you can't name the result sets, although I can't readily think of any reason why you would need to name the result sets... since the number and content of result-sets returned by stored procedures is entirely arbitrary -- and, in fact, needn't be from a table at all (SELECT NOW() AS server_time;) the application is required to understand -- in advance -- the nature of the results the server will return, and in what order.

They can be "identified" by their ordinal position in the responses from the server... the first unbounded SELECT that executes is what generates what you see as the first result set, the second one to execute generates the second, etc... always.

Stored procedures execute their instructions sequentially, within a single thread, so there's never a chance of the result-sets coming out in any order other than the order in which the SELECT statements are encountered in the program flow, no matter how long each query takes.

If the answer -- "no" -- leaves you with an unsolved problem, please consider expanding your question to explain what we're trying to solve.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top