LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: Disabled
Linux running MariaDB database


Hi

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

DELIMITER //
CREATE DEFINER=`root`@`%` PROCEDURE `UpdatePeriodLocaltime`(IN `startUtcTime` datetime, IN `tableName` VARCHAR(50))
BEGIN
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;

END IF;

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;


END//
DELIMITER ;

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?

P
 
Old 04-15-2015, 03:16 PM   #2
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 973

Rep: Reputation: 118Reputation: 118
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.
 
  


Reply


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 11:04 AM
LXer: Red Hat Enterprise Linux 7 beta arrives with MariaDB as its default database LXer Syndicated Linux News 0 12-11-2013 10:12 PM
LXer: Google dumps Oracle MySQL and goes running into the arms of MariaDB LXer Syndicated Linux News 0 09-26-2013 07:41 PM
LXer: Slackware switching to the MariaDB database LXer Syndicated Linux News 0 03-24-2013 09:42 PM
Running an M$ Access database from Linux DarkSTech Linux - Networking 3 03-17-2003 11:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:21 AM.

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