[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

adding value to IN variable

Posted on 2013-12-29
2
Medium Priority
?
201 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…
Suggested Courses

649 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