1

Topic: Whether to learn there is result SELECT in procedure? Without COUNT?

In procedure it is fulfilled "heavy" SELECT. How correctly to learn, whether there is a result (lines) of this request?

2

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

And where the result of it SELECT disappears?

3

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

miksoft;
Procedure is caused from php.
If the result of request exists, it and is given.
If the result is not present, another is fulfilled select, and its results are produced as result of operation of procedure.

4

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

In such variant, probably, it can be made only in PHP.
If the initial request can be modified, it is possible to be played with function LAST_INSERT_ID () with parameter.

5

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

miksoft;
Thanks. It is a pity that there are no variants. As in PHP to make I know.

6

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

kealog;
And it is impossible to modify initial request?

7

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

kealog wrote:

In procedure it is fulfilled "heavy" SELECT.

And how much on a maximum the result of performance of this request is heavy? Can, is more reasonable do sampling not at once in an output flow, and in the temporary table? There to look at a record count - time to spit... If a zero - that in the same table to make and the second sampling. And before an output of procedure to do unconditional SELECT from TEMP in an output flow.

8

Re: Whether to learn there is result SELECT in procedure? Without COUNT?

Schematically:

CREATE PROCEDURE
CREATE TEMPORARY TABLE temp ENGINE=Memory
SELECT/* 1 */INTO temp
SELECT COUNT (*) INTO @cnt FROM temp
IF @cnt=0 THEN
SELECT/* 2 */INTO temp
END IF
SELECT * FROM temp
-- DROP TABLE temp
END