Этот код будет работать. Вот демоверсия . Настройте объявленные переменные в соответствии с типами столбцов таблицы.
CREATE PROCEDURE getdetails()
BEGIN
DECLARE finished INTEGER DEFAULT 0; --this is added so the exit from loop can be made
DECLARE vin int;
DECLARE responseTimeStamp int;
DECLARE odometer int;
DECLARE chargePercentage int;
DECLARE sequential_vehicle_status
cursor for
SELECT vin
, responseTimeStamp
, odometer
, soc
FROM `table`
ORDER BY vin, responseTimeStamp;
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET finished = 1;--this is added so the exit from loop can be made
OPEN sequential_vehicle_status;
start_loop: LOOP
IF finished = 1 THEN
LEAVE start_loop;
END IF;
FETCH sequential_vehicle_status into vin
, responseTimeStamp
, odometer
, chargePercentage;
select concat(vin, '*', responseTimeStamp, '*', odometer, '*', chargePercentage, '% ');
END LOOP;
CLOSE sequential_vehicle_status;
END;
Прочтите комментарии к своему вопросу. DBMS_OUTPUT - это oracle пакет. Вместо этой строки кода dbms_output вы можете добавить это:
select concat(vin, '*', responseTimeStamp, '*', odometer, '*', chargePercentage, '% ');