Crear array en procedimiento de mysql
Publicado por jose (20 intervenciones) el 06/06/2023 09:36:43
Buenas,
Estoy intentando crear un array de ids de una tabla, y me está dando el siguiente error:
Unexpected character. (near "[" at position **)
Este es el código de pruebas que estoy haciendo para implementarlo en el procedimiento
Muchas gracias,
Estoy intentando crear un array de ids de una tabla, y me está dando el siguiente error:
Unexpected character. (near "[" at position **)
Este es el código de pruebas que estoy haciendo para implementarlo en el procedimiento
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
DELIMITER $$
CREATE PROCEDURE test(anovar INT)
BEGIN
DECLARE a INT Default 0;
DECLARE totaltest INT Default 0;
SET totaltest = (SELECT count(*) from test where estado in (0,1));
SELECT concat('total: ',totaltest);
DECLARE test_ids INT AS ARRAY [totaltest];
simple_loop: LOOP
IF a=totaltest THEN
LEAVE simple_loop;
END IF;
SET test_ids[a] = (SELECT id from test where id = a AND estado in (0,1));
SET a=a+1;
END LOOP simple_loop;
END $$
Muchas gracias,
Valora esta pregunta


0