Avatar of Jayesh Acharya
Jayesh Acharya
Flag for United States of America asked on

Create Procedure in MariaDB 10.2.15

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;

Open in new window

* MariaDBDatabases

Avatar of undefined
Last Comment
PortletPaul

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
PortletPaul

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23