troubleshooting Question

Create Procedure in MariaDB 10.2.15

Avatar of Jayesh Acharya
Jayesh AcharyaFlag for United States of America asked on
Databases* MariaDB
1 Comment1 Solution75 ViewsLast Modified:
I need some basic help with syntax for mariaDB 10.2.15
I am using MySQL workbench to execute the sqls below but I can seem to get the syntax to work. I have tried to use the information from MariaDb websites directly but I am not having much luck.

If I could get this version of code working I can figure out the rest of my issues. Thanks

create procedure testProc ()
BEGIN

	declare 	loopCounter INT;
    declare     loopCounterMax INT
	declare 	startCounter INT;
    declare     EndCounter INT;
        
	SET loopCounter = 100;
    SET loopCounterMax = 1000001;
	SET StartCounter = 0;
    SET EndCounter = 1;
    
    label1: WHILE EndCounter < loopCounterMax DO
		SET EndCounter = EndCounter + startCounter;
        
        SET @s = concat(
		'insert into testsch.customerevents_01 
		select a.*
		from testsch.customerevents a
		where exists
			(select 1
			 from testsch.custeventTID_01 b 
			 where a.TID = b.TID
			 and b.sql_row_id > ',startCounter'
			  and b.sql_row_id < ',EndCounter '
			) ');
		PREPARE stmt from @s;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;

		SET startCounter = EndCounter -1;
	END WHILE label1;
END;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros