I am getting this error when I try to run Stored Procedure in liquibase.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘create procedure insert_into_backup_table()
script in Mysql (ran without error)
delimiter #
create procedure insert_into_backup_table()
begin
declare orginalName varchar(255);
declare max_value int unsigned default @countAllIds;
declare counter int unsigned default 0;
start transaction;
while counter <= max_value do
set orginalName = (select area_name
from tmp_kpi_area
where id = counter
);
update tmp_kpi_area
set area_id = (
select id
from kpi_area area
where name = orginalName
Limit 1
)
where id = counter;
set counter=counter + 1;
end while;
commit;
end #
delimiter ;
call insert_into_backup_table();
in the liquibase changset:
<changeSet id="SAM-2520-Remove-SZ-from-areas-6" author="mail.com">
<sql dbms="mysql" splitStatements="true" end-delimiter="#">
<createProcedure>
<![CDATA[
set @countAllIds = (select count(id) from tmp_kpi_area);
drop procedure if exists insert_into_backup_table;
#
create procedure insert_into_backup_table()
begin
declare orginalName varchar(10);
declare max_value int unsigned default 25;
declare counter int unsigned default 0;
start transaction;
while counter <= max_value do
set orginalName = (select area_name
from tmp_kpi_area
where id = counter
);
update tmp_kpi_area
set area_id = (
select id
from kpi_area area
where name = orginalName
Limit 1
)
where id = counter;
set counter = counter + 1;
end while;
commit;
end
#
]]>
</createProcedure>
</sql>
</changeSet>
But I am getting error in here. Could you please help me to correct the liquibase query. thanks all