?
Solved

adding value to IN variable

Posted on 2013-12-29
2
Medium Priority
?
200 Views
Last Modified: 2013-12-29
I need to assign 21600000 to fromDate IF the value originally sent in is zero

Code that I have now is


CREATE PROCEDURE reportFreeCooling(
  IN fromDate VARCHAR (50),
  IN toDate   VARCHAR (50),
  IN timeZone VARCHAR (50)
)
BEGIN
  DECLARE startDate VARCHAR (50);
  DECLARE endDate   VARCHAR (50);
  DECLARE startDateOriginal VARCHAR (50);
  DECLARE mylogID   INT;
  DECLARE myItemId varchar (50);
  DECLARE myItemId2 varchar (50);
  DECLARE xHours varchar (50);
  DECLARE endHoursNull varchar(50);
  DECLARE endHoursNotNull varchar (50);

 

Open in new window


and of course the rest of the stored procedure. The rest is correct I just need to know how to change the fromDate if zero is what is sent in.
0
Comment
Question by:portlight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:portlight
ID: 39745336
I have tried this but it is also not working
basically this is what i need to code to do.....

 IF fromDate = 0 THEN 
  SET @fromDate = '21600000';
  IF fromDate > 0 THEN SET @romDate = fromDate;
  SET startDate = FROM_UNIXTIME(@fromDate/1000); 

Open in new window

0
 
LVL 24

Accepted Solution

by:
mankowitz earned 2000 total points
ID: 39745440
This works for me:

CREATE DEFINER=`root`@`localhost` PROCEDURE `reportFreeCooling`(
  IN fromDate VARCHAR (50),
  IN toDate   VARCHAR (50),
  IN timeZone VARCHAR (50)
)
BEGIN
	IF fromDate = 0 THEN SET fromDate = '23423'; END IF;
	SELECT fromDate;
END

Open in new window

0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question