Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-03-2015, 02:24 PM   #1
LQ Newbie
Registered: Apr 2015
Posts: 1

Rep: Reputation: Disabled
Linux running MariaDB database


I have MariaDB running on Linux. I have created a stored procedure:

CREATE DEFINER=`root`@`%` PROCEDURE `UpdatePeriodLocaltime`(IN `startUtcTime` datetime, IN `tableName` VARCHAR(50))
DECLARE period, localperiod, startrange, endrange datetime;
declare _offset time;
declare endtime datetime;
declare _dstStart, _dstEnd date;
declare statement varchar(256);

SET period = startUtcTime;

set endtime = addtime(startUtcTime,'1 00:15:00');

select offset, dstStart, dstEnd from timezone into _offset, _dstStart, _dstEnd;

if (startUtcTime >= _dstStart and startUtcTime < _dstEnd) then
set _offset = addtime(_offset, '01:00:00');
end if;

periods_loop : LOOP

IF period >= endtime

THEN leave periods_loop;


set localperiod = addtime(period, _offset);
set startrange = addtime(period, '-00:07:30');
set endrange = addtime(period,'00:07:30');

UPDATE updperiod SET timest = period;

set @sql = concat('update ', tableName, ' set periodlocaltime = "', localperiod, '" where starttime > "', startrange, '" and starttime <= "', endrange, '"');

#UPDATE pre_mib2 SET periodlocaltime = addtime(period, _offset) WHERE starttime > (addtime(period, '-00:07:30')) AND starttime <= (addtime(period,'00:07:30'));

prepare stmt1 from @sql;
execute stmt1;
deallocate prepare stmt1;

set period = addtime(period, '00:15:00');

END loop;


But when I try to call the procedure I get the following error:

mysql> call UpdatePeriodLocaltime("2015-04-02","table_name");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1

I have created another procedure with only one IN parameter and that works just fine...

What am I missing here?

Old 04-15-2015, 04:16 PM   #2
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 995

Rep: Reputation: 128Reputation: 128
Recommendation (even if you've solved your issue):
decouple the two things.
Use MariaDB (or whichever DB - even Oracle or DB2) just to store/retrieve/link data, and use a programming language to handle it.
Reasons are a bit complex - on a long run (or on a short run with changes to the DB-infrastructure) you won't regret it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MariaDB database is broken or not working correctly? corrupted maybe? cyberdome Linux - Newbie 3 04-07-2014 12:04 PM
LXer: Red Hat Enterprise Linux 7 beta arrives with MariaDB as its default database LXer Syndicated Linux News 0 12-11-2013 11:12 PM
LXer: Google dumps Oracle MySQL and goes running into the arms of MariaDB LXer Syndicated Linux News 0 09-26-2013 08:41 PM
LXer: Slackware switching to the MariaDB database LXer Syndicated Linux News 0 03-24-2013 10:42 PM
Running an M$ Access database from Linux DarkSTech Linux - Networking 3 03-17-2003 12:05 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration