Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am using a stored procedure, that truncates a partitioned table.
And I pass the table name as a parameter to the stored proc. And inside, the stored proc, there is a dynamic sql that truncates the table as per the table name 'in' parameter. The procedure is as follows
DELIMITER $$
CREATE DEFINER=`mpadmin`@`%` PROCEDURE `mysqlproc`(in isactivetoproc int, in tablename varchar(255))
begin
set @sql = concat('alter table ',tablename, ' truncate partition pactive');
if isactivetoproc = 1
then
prepare stmt from @sql;
execute stmt ;
deallocate prepare stmt;
end if;
end$$
DELIMITER ;
I have tested this on mysql and it works fine. But when I call it through talend , it keeps saying there is a syntax error.
However, when I don't use the dynamic sql and use regular SQL, and call through talend it works.
DELIMITER $$
CREATE DEFINER=`mpadmin`@`%` PROCEDURE `mysqlproctest`(in isactivetoproc int, in tablename varchar(255))
begin
alter table farmer truncate partition pactive;
end$$
DELIMITER ;
My intention is to reuse the procedure for all tables.
Any thoughts on why the first proc is not working
Thanks
Rathi