AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Multiple Results in Query (https://forums.alliedmods.net/showthread.php?t=333450)

ConorCC 07-12-2021 16:53

Multiple Results in Query
 
Hello there!

Using SQLx is it possible to create a query that contains multiple SELECTs? I have created one but I only can receive the first one. Maybe I can switch between them later?

For example if I call a procedure then a select the result won't be set. The plugin says "[MySQL] No result set in this query!".

Of course I can put the select in the procedure and the problem is gone but I don't think it's a nice solution.

Thank you!

Natsheh 07-12-2021 17:49

Re: Multiple Results in Query
 
I hope this answer your question

Bugsy 07-12-2021 18:11

Re: Multiple Results in Query
 
UNION will work, but why not just set the query conditionally?

Code:

if ( some condition is true )
  SELECT A, B, C
else
  SELECT D, E, F

"Of course I can put the select in the procedure and the problem is gone but I don't think it's a nice solution."

Then don't
PHP Code:

CallQuerybool:bSomeCondition )
{
    if ( 
bSomeCondition )
        
SELECT ABC
    
else
        
SELECT DEF
}

public 
client_connectid )
{
    if ( 
is_user_botid ) )
        
CallQuerytrue )
    else
        
CallQueryfalse );

    
//or
    
CallQueryis_user_botid ) );



ConorCC 07-13-2021 01:05

Re: Multiple Results in Query
 
I think you missunderstood.

Here is my code.

PHP Code:

CALL `CX_TEST`('%i', @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14); 
SELECT @p1 AS `r_error_code`, @p2 AS `r_error`, @p3 AS `r_id`, @p4 AS `r_item_id`, @p5 AS `r_user_id`, @p6 AS `r_in_use`, @p7 AS `r_expiration`, @p8 AS `r_amount`, @p9 AS `r_new_id`, @p10 AS `r_new_item_id`, @p11 AS `r_new_user_id`, @p12 AS `r_new_in_use`, @p13 AS `r_new_expiration`, @p14 AS `r_new_amount`; 

Let me explain. I call the CX_TEST procedure that using output parameters from @p1 to @p14. So after it's executed the only thing I have to do to select the variable values.

In this case I must run both scripts in one query but since I call the CX_TEST first and then the select the sql result will be empty.

ConorCC 07-13-2021 11:14

Re: Multiple Results in Query
 
Fixed! I put the whole script into an another procedure so when I call the new one the response is what I expected.


All times are GMT -4. The time now is 02:33.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.